I know this is somewhat hot off the heels of my last question, but after fixing some other problems to Build a .pyd file after using interrogate, I have (presumably) just one more error before I can successfully Build a DLL, rename it to a pyd, etc.
When I try to build, I get the error message:
Error C2664 'PointerToBase<T>::PointerToBase(CollisionNode *)': cannot convert argument 1 from 'Y *' to 'CollisionNode *' p3fst-ent C:\Panda3D\include\pointerTo.I 50
When I examine the relevant line in PointerTo.I, or more specifically line 49-52 It reads:
So I’m assuming that for some reason Visual Studio is reading “Y *” instead of “Y *ptr”. I’m honestly stumped as to what may be causing this. Also, if it helps here’s my Build Output:
Build started...
1>------ Build started: Project: p3fst-ent, Configuration: Release x64 ------
1>playerEntBase_igate.cxx
1>C:\Panda3D\include\pointerTo.I(50,19): error C2664: 'PointerToBase<T>::PointerToBase(CollisionNode *)': cannot convert argument 1 from 'Y *' to 'CollisionNode *'
1> with
1> [
1> T=CollisionNode
1> ]
1> and
1> [
1> Y=const char
1> ]
1>C:\Panda3D\include\pointerTo.I(50,20): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>C:\Panda3D\include\pointerToBase.h(35,3): message : see declaration of 'PointerToBase<T>::PointerToBase'
1> with
1> [
1> T=CollisionNode
1> ]
1>C:\Users\trici\Documents\GitHub\Panda3D1st\gamecode\acrossGame\cpp\p3fst-ent\playerEntBase.h(47): message : see reference to function template instantiation 'PointerTo<CollisionNode>::PointerTo<const char>(Y *) noexcept' being compiled
1> with
1> [
1> Y=const char
1> ]
1>C:\Users\trici\Documents\GitHub\Panda3D1st\gamecode\acrossGame\cpp\p3fst-ent\playerEntBase.h(47): message : see reference to function template instantiation 'PointerTo<CollisionNode>::PointerTo<const char>(Y *) noexcept' being compiled
1> with
1> [
1> Y=const char
1> ]
1>Done building project "p3fst-ent.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
They say only a bad workman blames their tools, but I tried updating visual studio. This changed the error to “PointerToBase::PointerToBase’: none of the 4 overloads could convert all the argument types p3fst-ent C:\Panda3D\include\pointerTo.I”
Despite the new language, I still feel like chances are the error is probably due to something I’m doing wrong. Anyway, back to the drawing board.
#pragma once
#ifndef PLAYERENTITYBASE
#define PLAYERENTITYBASE
#ifdef CPPPARSER
#define PUBLISHED __published
#else
#define PUBLISHED public
#endif
#include "actorNode.h"
//#include "pandabase.h"
#include "collisionBox.h"
#include "collisionSphere.h"
#include "collisionSegment.h"
#include "collisionNode.h"
class playerEntBase : public ActorNode{
PUBLISHED:
playerEntBase();
bool is_standing = false;
};
playerEntBase::playerEntBase()
{
//Give the ActorNode base a name
ActorNode("default Playertype");
//Set up the main bounding box
PT(CollisionNode) boxNode = new CollisionNode("collBumpHolder");
PT(CollisionBox) hitbox = new CollisionBox(LPoint3(0, 0, 0),PN_stdfloat(6),PN_stdfloat(6),PN_stdfloat(9.75));
boxNode->add_solid(hitbox);
boxNode->set_from_collide_mask(BitMask32(0x3)); //red masks are used as the default, team based games shouldnt use this constructor
boxNode->set_into_collide_mask(BitMask32(0x4));
this->add_child(boxNode);
delete hitbox;
//Set up the four spheres used for detecting raised surfaces the character can climb up
PT(CollisionNode) sphereNode("collRampHolder");
sphereNode->set_from_collide_mask(BitMask32(0x3));
sphereNode->set_into_collide_mask(BitMask32(0x0));
this->add_child(sphereNode);
for (int i = 0, sphereX = 6, sphereY = 6;i < 4; i++) {
//this could probably be better
PT(CollisionSphere) tempSphereVar = new CollisionSphere(sphereX, sphereY, -7.75, 2);
tempSphereVar->set_tangible(false); //see above
sphereNode->add_solid(tempSphereVar);
delete tempSphereVar;
if (i == 1) {
sphereY = -6;
sphereX = 6;
}
else {
sphereX = -6;
};
};
//create the collision Segment, for checking whether or not a character can be considered "standing"
PT(CollisionNode) segmentNode("collStandHolder");
segmentNode->set_from_collide_mask(BitMask32(0x3));
segmentNode->set_into_collide_mask(BitMask32(0x0));
this->add_child(segmentNode);
PT(CollisionSegment) tempSeg = new CollisionSegment(0, 0, 0.1, 0, 0, -9.80);
segmentNode->add_solid(tempSeg);
tempSeg->set_tangible(false);
delete tempSeg;
};
#endif
I’m not a C++ expert, but you requested dynamic memory, then deleted the link to it. I’m not sure if the add_solid method copies the data. Maybe he’s just passing a link. I think it makes sense to try not to use delete
Sorry for the late reply, I’ve been busy with work. That being said, I looked into it in my spare time and all add_solid does is add the parameter to a pvector of type cowpt and mark the node for having it’s internal bounds recomputed.
From what I can find on pvector, it’s “just a version of stl vectors specialized for p3d”. I think this article says that vectors do in fact copy data. I was also worried for a bit that using add_solid might not update the reference count, but it seems that I don’t need to worry about that either.
Anyway, i’ll go back to finding where constant Y is declared.
This is probably the problem. You are trying to assign a char * to a PT(CollisionNode), which is an invalid pointer conversion. You probably forgot the = new CollisionNode("collRampHolder").
How Embarrassing!
Anyway, that along with solving a few other errors did it. I now have compiled successfully, and am about to test this out to ensure everything went alright.