Hello there!
I recently decided to start up a new project, so far everything is running along excellently... or atleast it was until I ran into my Cuts-problem.
It was while working on my NPCs detection function that problems appeared.
The function basically creates a cone extenting from right in front of the NPCs head to a certain distance based on a variable.
Code:
Character* Character::scanView()
{
Cone theView;
theView.set(0, getSightRange()/3, getSightRange(),
cskel.getPoint("Head").pos+cskel.getPoint("Head").dir,
cskel.getPoint("Head").dir);
Box theBox(getSightRange()+getSightRange()/10, pos());
Memb<Obj*> theObjects;
Game::World.objQuery(theObjects, theBox);
REPA(theObjects)
{
if(Character* theCharacter = CAST(Character, theObjects[i]))
{
if(theCharacter != this)
{
// Check if the character is a friend or not
if(theCharacter->getFaction() != getFaction())
{
Box charBox = theCharacter->mesh->box;
charBox += theCharacter->pos();
// I never pass this if-statement
if(Cuts((Shape)theView, (Shape)(charBox)))
{
return theCharacter;
}
}
}
}
}
return NULL;
}
I've drawn all shapes to the screen and they all look like they're supposed to. But for some reason I never get past the "if(Cuts((Shape)theView, (Shape)(charBox)))" line.
The reason for the (Shape) type-cast is that the engine wouldn't recognize theView and charBox as Shapes. I converted theView and charBox to Shapes and then drew them to make sure they were still correct, and they appeared to be.
So anyone, please tell me, what am I overlooking?
Grateful for any and all answers
// Myx