CastRay on small collision meshes?
by Daniel Buckmaster · in Torque Game Engine · 01/28/2010 (7:47 pm) · 11 replies
I'm using a castRay to find objects that the player can interact with. This works fine for my large gun mesh, but for some reason I couldn't ever select my grenade, even when looking straight at it, very close up. However, I made the grenade's collision mesh larger and re-exported it, and now it seems to work.
Is there some difficulty in doing a raycast against objects with small collision meshes?
Is there some difficulty in doing a raycast against objects with small collision meshes?
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
01/28/2010 (9:56 pm)
I tried looking around the grenade to all sides and it never seemed to pick it up. Also, the raycast does appear to be working properly for other objects (i.e., when I just edge it over where the collision mesh should be, the object is selected).
#3
I found I had a similar problem with interacting with buttons and small control panels. I had to make the bounding box large on these objects so the player could interact with them.
Also, I know this is obvious, but you haven't overlooked the bitmask?
01/28/2010 (11:08 pm)
Isn't raycast calculated on the object's bounding box, not the collision mesh?I found I had a similar problem with interacting with buttons and small control panels. I had to make the bounding box large on these objects so the player could interact with them.
Also, I know this is obvious, but you haven't overlooked the bitmask?
#4
I don't remember exactly what mesh does the raycast test for.
Nicolas Buquet
www.buquet-net.com/cv/
01/29/2010 (3:35 am)
Did you try to integrate to your DTS a bounding box, a collision mesh and a LOS mesh.I don't remember exactly what mesh does the raycast test for.
Nicolas Buquet
www.buquet-net.com/cv/
#5
01/29/2010 (7:45 pm)
Quote:Isn't raycast calculated on the object's bounding box, not the collision mesh?Only on Players, who use a bounding box for all collision by default. ShapeBase objects use their collision or LOSCollision meshes for raycasts and other collision.
Quote:I had to make the bounding box large on these objects so the player could interact with them.That sounds like the problem I'm having.
Quote:Also, I know this is obvious, but you haven't overlooked the bitmask?Yep, definitely sure. I can use the exact same datablock with a different shape and it works fine. Also, like I said, re-exporting with a larger collision mesh makes it work fine as well.
Quote:I don't remember exactly what mesh does the raycast test for.Looking through the code, it seems that ShapeBase casts rays against its LOSCol meshes, which are the same as its regular collision meshes if you don't provide dedicated LOS collision meshes. I'll try adding a LOS col mesh - maybe I can just make that larger. However, I'd still prefer to be able to cast rays against any small object I like. Hmm...
#6
02/01/2010 (3:46 pm)
This is an issue we had when creating small objects in Onverse. I never actually spent the time to try and debug it but we did exactly what you're thinking. Creating an LOS collsion mesh that was large enough to click.
#7
02/01/2010 (5:41 pm)
All right, well, I'm calling this a bug, and it's necessarily a problem with castRay on the TSMesh (or whatever is below mShapeInstance) level, since Shapebase::castRay doesn't really do much but call that.
#9
02/07/2010 (12:44 pm)
That looks like it addresses the issue! I'll test it next week when I get back to my dev comp. Any idea of performance hits with that method? Three cross products instead of one? Ah well - at least there's an idea of what causes the problem. Thanks!
#10
11/27/2010 (5:18 am)
So after getting back on my dev comp (:P...) I applied that fix to try and clear up some issues I was having with ShapeBase collision mesh raycasts. It's fixed those, so I think I can safely assume it will fix my small-mesh problem as well!
#11
11/29/2010 (12:55 am)
Only five months later ;)
Associate Steve Acaster
[YorkshireRifles.com]