meshesintersect

Blitz3D Forums/Blitz3D Programming/meshesintersect

(tu) sinu(Posted 2003) [#1]
i was using the meshesintersect command in a demo

if the player was a certain distance from a coin the meshesintersect would be checked and then the coin would be deleted, even if i removed the distance check, speed seemed fine.

i could have about 1000 coins on screen and speed was good with distancechecks.

now when i try it with a meshesintersect on my basic level(meshesintersect(player_mesh,Level_mesh) the speed drops to about 10fps. the level has about 500 polys.

anyone explain why?
i know its a slow command.


Robert(Posted 2003) [#2]
Each poly of the player presumably has to be tested against each poly of the mesh, which is very slow.

Maybe a better option if the in-built collision isn't good enough would be to use linepicks?


(tu) sinu(Posted 2003) [#3]
it was just mainly a test for a boundingbox on my player but the speed loss is too great, the bounding box mesh had about 20polys.


Bot Builder(Posted 2003) [#4]
but that's still 10,000 checks per frame. why not use blitzes collisions? and why does a bounding box have 20 polys? shouldn't it only have 12?


(tu) sinu(Posted 2003) [#5]
12 then, i was just making a rough guess :)


joncom2000(Posted 2003) [#6]
Strange, i've had a level up and running with over 8000 polys and used meshintersects for collisions with pickups with no slowdown at all. Rock solid 85fps.

I think you must have either a mistake in your polycount or something else in your code is slowing it down.

You say there are 1000 coins well that means that even if your using a flat quad your polycount is 2000.

Jon


(tu) sinu(Posted 2003) [#7]
no, i did a test without coins and only a meshesintersect for the box intersecting with level.


lecks(Posted 2003) [#8]
How many polys does your player mesh have?

I dont think meshesintersect uses the collisionbox. It even warns in the help:

This is a fairly slow routine - use with discretion...


I'd try something like this:
[CODE]
;do this during initialization
EntityBox player_mesh,centerx#, centery#, centerz#, xsize#,ysize#,zsize#
;in your loop
noofcollisions = countcollisions(player_mesh)
for i = 1 to numberofcollisions
entitythatgothit = collisionentity(player_mesh, i)
dosomethingto(entitythatgothit)
next
[/CODE]
i'm just guessing though, i could be wrong :)


(tu) sinu(Posted 2003) [#9]
what i did was create a cube around my player and set it's alpha to 0 then used that to check meshesintersect because the command checks the mesh on the entities specified.


lecks(Posted 2003) [#10]
i just wouldnt recommend using a command that mentions that it's slow in the help, when you could use another command to get the same effect :).


jhocking(Posted 2003) [#11]
Commands which are referred to as slow are not too slow to use one or two times every frame; commands which are that slow (such as several 2D image manipulations) specifically state not to use it while the game is running. Commands like MeshesIntersect are slower than other stuff like moving entities but you should still be fine using it a couple times every frame; faster commands you routinely use hundreds of times every frame. As an example, I am using MeshesIntersect once a frame right now and am not having any drop in framerate.

So the main thing you should check for is how many times you are calling MeshesIntersect every frame. It is possible that you are accidentally using the command in the middle of a loop.


(tu) sinu(Posted 2003) [#12]
something is going on because if i do a meshesintersect between my players mesh and level i get no slowdown but if i create a sphere around him and parent it to him then do a meshesintersect between the sphere and the level, frames drop to about 10.

ps don't need to use it anyway, i had a problem with collision which i had in my other post (collisions post)and was gonna use a meshesintersect but have found a better way for my collisions to register without my player moving at all.


Gauge(Posted 2003) [#13]
You are running a different type for the coins right? meshintersect does that too? Or does meshintersect check all fo the meshes in the game. If it does not good to use.
Maybe you could:
when mob dies, get x/y/zof the mob, drop the coins etc.
then add a type coin...with fields max/min x/yz so the type would look like.
type powerup
field maxx
field minx
field maxy
field miny
field maxz
field minz
end type
then perhaps in your loop add:

for c.coin=each coin
if playerx <c\minx and >c\maxx
andz
andy
then delete the coins,add it to the players inventory, etc.
and each coin/powerup whatever loop could delete the coin atuomatically after so many frames have passed, etc?

Oh well, just a thought.


(tu) sinu(Posted 2003) [#14]
i won't be using meshesintersect now like i said but thanks for the help anyway.