is EntityVisible what's REALLY slow?

Blitz3D Forums/Blitz3D Programming/is EntityVisible what's REALLY slow?

syntax(Posted 2008) [#1]
I have some code that can return if an object can "see" another object but for it to work it has to be set and updated every loop. Then I found the wonderful world of EntityVisible or so I thought because now every time I drop it in the program it gets deathly slow. Is EntityVisable my problem or should I search for some other odd phenomenon that is slowing down the program?

Thanks


Stevie G(Posted 2008) [#2]
Entityvisible does the equivalent of a linepick between the source and destination entity. So, yes it could cause a major slowdown depending on your geom and number of times it's called during your main loop.

Stevie


t3K|Mac(Posted 2008) [#3]
you can speed up things if you set the pickmode of the entities which never can obscure other entities to false. its not the superduper speedup, but it helps. especially when you want to entityvisible() lights for coronas. in this case lots of meshes never can obscure them and the speedup of entityvisible() is more dramatic. depends on your scene though...


Ross C(Posted 2008) [#4]
Another thing, i have been experimenting with. What you do is, you need to set up a system of texture swapping though, so you need to keep track of all your entities and what textures they have.

You color the entity you want to check against red. You color the scenary and everything else black, point the camera at the entity. This has the effect of the exact middle of the camera being the middle of the entity, which entityvisible does. You set the camerarange to no more than the distance of the entity. Now, you render. You readpixel at the centre of the screen. If it's red, then you can see your entity. You read more pixels if you need more of it to be showing.

Reset everything for your second render. I know, i know. Sounds complicated and speed gain is highly debately. It's an expirement though :o)

You could try the old shoot a pivot at the entity, from the centre of the camera. Point the camera at the entity, fire the pivot. Check for a collision.


Dreamora(Posted 2008) [#5]
if you fire a pivot you can as well just use linepick with radius. but entityvisible does a little more than that, which it works even when the center line is obscured as one would assume from the command.

but you really only should use it when you need it and when it is intelligent to use it.
for larger scale usage, an own PVS system will be needed and isn't an optional thing anymore ... cause entityvisible wasn't meant for "check anything" tests and even thought todays computer are worlds faster than the old ones, PVS are still a must go for such operations so you can early drop all entities you definitely can not see.


Ross C(Posted 2008) [#6]
A pivot is far faster in my experience. When you start using a bigger than default raduis on a linepick, is takes longer to do.


IPete2(Posted 2008) [#7]
Syntax,

I rememeber a converation with tu sinu a while back, and if I'm right he says that in the Newton Physics wrapper (see userlibs) you can do the equivalent of the linepick command except it is faster than B3ds command.

It may be worth you downloading the wrapper and trying it before you buy it.

IPete2.


jfk EO-11110(Posted 2008) [#8]
You should use EntityVisible only when the distance is low. So a
If EntityDIstance(a,b)<max_sight# then
 seeme=entityVisible(a,b)
 if seeme bla
endif

may be useful.