RayCasting to find objects

I have searched around for an answer, but it seems that everybody wants to make voxel-based games, so they don’t apply to my particular case.

I have 512 spatials added to a TerrainQuad that make up the grass, and to be able to display them with a reasonable frame rate I have to use GeometryBatchFactory.optimize to merge them as one object. Doing that - and then casting a ray on a piece of grass returns a single geometry that represents all grass - as expected - and thus you cannot distinguish between each piece of grass.

So I read about the BatchNode, which, after calling .batch(), renders every geometry into one single mesh. But when adding this batchnode to the scece, 512 objects are present instead of what I expected to be one object, Performance is significantly reduced as a result, however, using this method allows me to cast a ray and find the piece of grass I am looking at.

How do I go about being able to have the performance that GeometryBatchFactory gives yet be able to pick out individual items using a ray?

Use the same algorithm you use to distribute the plants and check if you’re close to one (or make a map), a spheric approximation should suffice. That should also be way faster than checking the whole geometry.

ugh… so simple… thanks normen.

Next problem: will the grass be animated…
There have been several implementations of grass on the forums. Have you looked at them yet? It could save you some headaches. At least the threads will contain some discussion of problems they came across.

I wondered about animated vegetation for a while but to be honest I have a lot to get through and I don’t wan’t to get stuck in the mud. My priority today is to be able to remove and item and add it to the player’s inventory. I have this “get one thing done a day” mantra so I can keep moving forward. It’s really easy to spend a lot of your time perfecting something and run out of gas. I’m determined to see this through :-x

@jayfella said: I wondered about animated vegetation for a while but to be honest I have a lot to get through and I don't wan't to get stuck in the mud. My priority today is to be able to remove and item and add it to the player's inventory. I have this "get one thing done a day" mantra so I can keep moving forward. It's really easy to spend a lot of your time perfecting something and run out of gas. I'm determined to see this through :-x

Oh, man, I miss the days where the “one things” were small enough to do in a day. :slight_smile:

Well what I mean is that its easy to “just tweak this” or “just fix that” and at the end of the day you’ve got no further. “One thing” is subjective. It could mean anything really, but the intention is to have something in the game today that wasn’t there yesterday.

I’ve sold tons of desktop applications and websites as a professional software developer but this is my first time getting into games. The longest I’ve ever spent on a single project from start to finish is 6 or 7 months, and that was with two of us. I can see that timescale being a distant memory if I don’t stop messing about with flowers and pretty effects.

@jayfella said: Well what I mean is that its easy to "just tweak this" or "just fix that" and at the end of the day you've got no further. "One thing" is subjective. It could mean anything really, but the intention is to have something in the game today that wasn't there yesterday.

I’ve sold tons of desktop applications and websites as a professional software developer but this is my first time getting into games. The longest I’ve ever spent on a single project from start to finish is 6 or 7 months, and that was with two of us. I can see that timescale being a distant memory if I don’t stop messing about with flowers and pretty effects.

Amen.

And on the other hand, those things are nice to hold in your back pocket should you ever need a little motivation boost to get back to the harder stuff.