Game Development Community

Raycast crash on crosshair drawing

by Josef Jahn · in Torque Game Engine · 01/11/2003 (9:32 am) · 2 replies

Hiya all.

I just found a nasty crash that only happens when I have certain high-poly weapon models ingame.

In fps/guiCrossHairHud.cc:

...
   if (gClientContainer.castRay(camPos, endPos, losMask, &info)) {
      // Hit something... but we'll only display health for named
      // ShapeBase objects.  Could mask against the object type here
      // and do a static cast if it's a ShapeBaseObjectType, but this
      // isn't a performance situation, so I'll just use dynamic_cast.
      if (ShapeBase* obj = dynamic_cast<ShapeBase*>(info.object))
         if (obj->getShapeName()) {
            offset.x = updateRect.point.x + updateRect.extent.x / 2;
            offset.y = updateRect.point.y + updateRect.extent.y / 2;
            drawDamage(offset + mDamageOffset, obj->getDamageValue(), 1);
         }
   }
...

The raycast produces an access violation, in ts/tsCollision.cc in function castRay():

// run through objects and collide
      for (S32 i=start; i<end; i++)
      {
         MeshObjectInstance * mesh = &mMeshObjects[i];
         if (mesh->getTransform() != previousMat)
         {
            // different node from before, set up for this node
----------> previousMat = mesh->getTransform();
            mat = *previousMat;
            mat.inverse();
            mat.mulP(a,&ta);
            mat.mulP(b,&tb);
         }


It may well be caused by a model itself, since I'm using the Milkshape exporter...

I don't need the health display of other people anyway, still... Any ideas?

#1
02/25/2003 (4:08 pm)
I'm only a n00b with the torque engine but i solved a few ray crashes on my system by disabling collisions with certain objects - i think it was GameBase::disableCollision() or something. I am unsure about the weapon models - if they are gameBase objects, you may want to try that. But after checking out your bio, you probably already have :)
#2
03/25/2004 (3:45 pm)
Having this exact same problem in the same place with a MilkShape model. When a player throws an object, if the object hits the crosshair, it crashes at the exact same point. Anyone else having this problem?


Solutions?