[SOLVED] Use invisible objects for ray casting

Hey, :slight_smile:

in my ingame editor, I’m using a ray casting to detect the location of an object. Unfortunately, I’m using a custom mesh, that contains all of the worlds objects merged together. (To increase the FPS, the mesh is optimized (Faces, Vertices, …) :wink:)

So a ray casting would always return the same result: The giant mesh. My solution was to add the single objects in a specific range around the player and cull them (CullHint.Always). So, the objects are invisble, but are detected by the ray casting. :slight_smile:

The problem:

Because I have to add the single objects to the world, the FPS decrease… When I’m using just the merged mesh, I have around 350-380 FPS, with the 100-200 objects close to the player, the game runs with 100 FPS.

The problem is the count of objects (That one, that is showed in the default info at the left bottom of the screen) - Although the added objects are culled, they decrease the FPS. :frowning:

Is there any way to say the engine, that these objects don’t have to be rendered and so on and are just necessary for ray casting?

The best solution would be to detect the pointed object by the location of the ray collision with the merged mesh. In that case, I wouldn’t have to add the single objects and that would increase FPS. :smiley:

I really don’t know, how to describe my problem better - I guess, it’ll be really confusing for you. :frowning:

Anyway, maybe someony of you can help me,

destro :slight_smile:

Since the bullet algorithms for collision are more effective anyway how about using physics collision shapes and physics ray tests? That would allow you way more flexible collision detection even if you don’t use “physics” (as in falling boxes) per se.

I am already using “pseudo” physics for collision detecting. I’ll look into the physics ray tests later, thanks for that hint. :slight_smile:

(Although I have no idea, how that could solve my problem to detect the pointed single object from the giant mesh… :frowning:)

You can ave any kind of collision shape, also just parts of a greater mesh.

Ok, I’ve created an algorithm, that calculates the position of the “object-to-place” out of the collision location. :slight_smile:

(I’m using a kind of grid for the objects in the editor, so this was not soo hard :smiley:)

So I don’t have to add the little objects to the root node and the FPS stay fine.

Nevertheless, thanks for the hint with the physics ray test - Seems interesting. :slight_smile:

1 Like

Yep, good idea. Makes no sense to subdivide your world unnecessarily just for locating things.