collisions eat resources !

Blitz3D Forums/Blitz3D Programming/collisions eat resources !

mouss38(Posted 2003) [#1]
EntityType and EntityRadius/Box use a lot of fps....
If I create a scene with many monsters with collision detection, the program will slow down becauseof those commands....
Is there any solution to avoid that, shall I don't use collisions for each monsters ?


Rob(Posted 2003) [#2]
Tips:

Re-use collision id's! the more collision combinations you have, the slower it will run. For example:

Const C_player,C_level,C_enemy
Collisions C_player,C_level,etc
Collisions C_enemy,C_level,etc
Collisions C_player,C_enemy,etc

is more efficient than making a seperate collision statement for each individual enemy.


mouss38(Posted 2003) [#3]
I already use Collisions Constant ID...
I have only 4-5 lines of "Collisions A,B,etc"


Jeremy Alessi(Posted 2003) [#4]
Yes collisions slow your game down! There are a few solutions. For one you can use invisible lower polygon collision instead of polygon collision depending on how many polys you're using. Of course you're also using 40,000 types! Perhaps you're just learning?


Beaker(Posted 2003) [#5]
Also, you might want to look at methods of occlusion.


mouss38(Posted 2003) [#6]
no no i don't use 40.000 types with collisions lol
.... just 4....

I'm not learning because i'm working on this game since 1 year ("Heroes", see the worklogs)

I think I will use another solution : monsters can attack by group of 4-5, others are hidden (HideEntity to disable collisions) until the previous ones are killed...


Ice9(Posted 2003) [#7]
turn off collision on everything except what is near what is moving


mouss38(Posted 2003) [#8]
i have already tried this... but when there is 10 monsters near and moving..... ?


Jeremy Alessi(Posted 2003) [#9]

no no i don't use 40.000 types with collisions lol
.... just 4....



I was referring to your other post :)

Anyway, that game is looking pretty sweet. Good luck with it.

I can tell what I've learned about Blitz and it's collisions and how I optimized my games.

1. Like I stated above for nearly all objects we render a standard object (even if it's just a few hundred polys) and then we attach invisible (EntityAlpha(entity,0)) collision approxiamations to them. Even on landscapes we can cut our collisions and picks in half by doing this. On small objects we'll cut polys from 500 to 6 - 50 polys.

2. Put your linepicks and camerapicks on a timer. Most of the time you don't need to pick every frame and I've made games go from unplayable to silky smooth by only picking every 50 millisecs(). Also, try not to have too much pickable geometry. A pick is basically a collision, so if you're using EntityVisible() or anything like that you're checking for collisions basically. I'm assuming that you're using 10 monsters and they're probably using linepicks to figure out where they're going.

3. Keep a good balance between surfaces and polycounts. This has been mentioned a bazillion times. It's not good to have a single surface million polygon object, and it's also not good to have a million surfaces even if most are being occluded. Design your levels to strike a balance where you can occlude polys behind the camera but not use so many surfaces that the game crawls.

There's so much depth to optimization that I couldn't possibly cover it all, and in fact I don't know it all :) Hopefully, the above will help you out a little.


mouss38(Posted 2003) [#10]
thanks...
for the polycounts, there are less than 10.000 poly in the scene... My models don't have more than 500/600 polygons...

And your tipsabout linepicks is good and i will use it.


Ross C(Posted 2003) [#11]
i don't know if anyone else noticed this, but a good optimization is to keep surces below 2000 polys. I don't know what kinda of limitaion it is, but it definetly exist, once 2000 od polys is passed, there will be a slowdown, like blitz or direct x or the graiphics card doesn't like handling more than 2000 poly per surface. By my tests anyway.


jfk EO-11110(Posted 2003) [#12]
Try not to use Collision whenever possible. When the Entitydistance from the Player Char to the Monster is so near that they will touch eachother then turn it on temporarily (just set the EntityType to a specific Value and later set it to Zero again to turn it off again). To prevent the Monsters crossing their ways and walk trough their Bodies try to use EntityDistance as well. To walk around something you really don't need Polygon-perfect Collision. You might use full sphere to polygon-Collision for the Player Character to the Ground and Enviroment.

It is a bad Idea to use a Collision-based AI for NPCs. Better use a Grid of legal zones or Waypoints.