How to do really fast EntityVisible commands

Blitz3D Forums/Blitz3D Programming/How to do really fast EntityVisible commands

JoshK(Posted 2003) [#1]
I tried randomly placing 30 lens flares in the stratus map, which each do one visibility check per loop. I got 2FPS. Then I tried checking just the level, without the static meshes, and it was very fast.

I wrote a fastentityvisible() function that first checks just the level. If the entities are occluded, you know you can return false.

Then it goes through each static mesh and checks visibility with the mesh's box. If the box of the mesh occludes the entities, then it checks against the mesh's actual polygons.

This allowed me to run 30 flares at the maximum framerate, in a pretty high-poly map.


This will included in the public code I release.


JoshK(Posted 2003) [#2]
When I made the updateflares() function run only before a render, I got 40 fps with 100 flares.


JoshK(Posted 2003) [#3]
And 100-300 fps with 20 flares.


sswift(Posted 2003) [#4]
So what you are basically saying is that Mark's function to dtermine is an entity is visible or not does not first check against the object's bounding box before attempting to check against the polygons themselves.

And that you should check against the level first, because the level will almost always occlude most flares, whereas individual small decorative entities in a level will only very rarely occlude any flares.


JoshK(Posted 2003) [#5]
1. Yes

2. Yes, and also consider that large decorative meshes might sometimes occlude things often, but if a simpler object also occludes it, it is faster to check the simpler object and not have to check the complex one.


I was a little surprised that the occlusion doesn't check the bounding box first. This makes a huge speed difference.


mrtricks(Posted 2003) [#6]
Would this make any difference to checking if a pivot is visible?


sswift(Posted 2003) [#7]
Yes.

When you check to see if an entity is visible, it really only looks to see if it's center is visible, or it's bounding sphere, I forget which. It does not look for the actual polygons.

But this is checked against the actual polygons of all objects in the world marked as occluders.

So only the polygons in the occluders matter.


t3K|Mac(Posted 2006) [#8]
@leadwerks: sorry for digging out this old thread - but i am in need of a fast entityvisible() command. i have lots of flares in my game, and they are crunching up my framerate. do you have a useful source?


MadJack(Posted 2006) [#9]
t3kMac

I'm going to have look at entity visibility as well - my tank game has a lot of vis checking going on and B3d's standard linepicking is a real bottleneck.

I'm holding out for the Nuclear Glory collision lib, but in the meantime, I wonder if using Coldet for vis checking might be quicker?


Sir Gak(Posted 2006) [#10]
@MadJack:

LOL! Great sig! Adapted from Starship Troopers, right?


b32(Posted 2006) [#11]
I saw an example in the archives last week that freed entities instead of hiding them. The idea was that a lot of entities causes slowdown. However, I couldn't find it anymore. But still it might be a good idea to check the archives. The flares, that are sprites, right ? Otherwise you could try collapsing the flares into a single mesh.


t3K|Mac(Posted 2006) [#12]
my flares are sprites (they are added runtime) - its the visibility check which is sooo slow.