enable/disable collision ? (lod and optimisation purpose)

hi,

I’d like to enable the collision detection on objects only where they are close to the player object : my scene is big, with a lot of meshes and the goal is to improve the frame rate.

I noticed that you can gain some extra frame by doing this.

the way I think about is to replace a mesh with collision enabled face by another face with collision disabled faces. it could combine with the draft lod script I’m doing apart.
maybe also I could end/add the object…

do you know the right way to switch on/off collision detection on an object ?

thanks.

in short, every object that needs to collide with something else then a player must have a collsens of its own

the others, which will NEVER have to collide with anything but the player,
can be targeted through the players inherited python scripts.

that way you maybe can save a lot of sensors (if you havent built your scene that way till now)

if you follow the rule:


if in_doubt and it_moves:
    put a collision sensor on it

nothing bad should be happening to your scene.

more info about the python scripts needed i will give you later, gotta work now, sorry

i hope that helps for first thoughts about improving,

greetings
manarius

mm in fact I never had to use the coll sensor until now… I manage collision through mesh faces.
I investigate this, thanks.

then stick to the things i pointed out above.

as few sensors as positive and you should be set.

in fact my objects always constist of:
empty - the central logical brain of the object
-> armature - no collision object
-> mesh - no collision object
-> collision mesh - sensor collision object

and within python i set the collision sensor of objects using:
act.usePosPulseMode = 1 (pulses positive) or 0 (does not pulse positive)
same for:
useNegPulseMode, tap
thats the only way i can imagine to disable a sensor, since complete unlinking is not part of the docs

the collsensor should be on the collision mesh and pointing to a script on the empty.

hope that helps further, still bughunting for a presentation, so still busy, sorry

greetings
manarius

If your collision meshes are low poly(0-30 polys) invisible objects and are the only objects that have collisions enabled on the scene, your frame rate will not change(or will change very minimal) if you disable there collisions.
It is most likely your slow downs are caused by something else, like always sensors set to 0 pulse mode, a lot of near sensors, cycling python scripts, using glsl unwisely, a lot of armatures in the scene, not using some kind of lod system etc.

The following thread :
LOD system : obj.visible=False vs empty mesh
This is not a big help, but this is related (I guess).

Thanks alot manarius, that description of your techniques was very helpful, and contained just what I was looking for. usePosPulseMode=1 (that function wasn’t work for me, but I didn’t realize you have to put =1 or 0) Disabling and Enabling sensors is so crucial. Thanks again!