Buffered states suggestion and questions about physics LOD
Posted: Mon Nov 05, 2012 4:29 pm
Hi Norbo,
I've been using buffered states with my game and I really like the feature. I would like to suggest perhaps the Entity could have a GetCurrentWorldTransform(out Matrix) that would automatically call down into either the Entity.WorldTransform or the BufferedStates.States.WorldTransform depending on the setting in Space.BufferedStates.Enabled. This would make it so people wouldn't have to refactor code to explicitly use (or not use) the buffered states while trying out different things; I had several bugs related to (my) oversights on the use of Entity.WorldTransform when buffering is enabled which made me think that perhaps this would be well suited for a wrapper at the Entity level. On a related note, it would be nice if the various properties that refer to Matrix objects had out/ref method versions to reduce the copy overhead (I haven't tested this myself but it seems to be the consensus that returning matrices and even Vector3's by out parameter is faster than a property and is worth doing when possible).
The other question bordering on a suggestion is related to the way the Space is updated. It would be really helpful if there was some way to continue to do an update at a fairly high rate but have some objects in the distance or otherwise less visible or less important save some cycles by reducing the amount of work done for them at a cost of simulation accuracy. Basically, LOD the physics in some way. I was wondering if there would perhaps be some way to make an Entity provide a heuristic 0..1 that would cause the object to be updated less often or less accurately (between some minimum and full rate as controlled by this heuristic). This is approaching the edge of my familiarity with Bepu's internals but I'm thinking one part of this sort of thing could be along the lines of a PositionUpdater that does the full update for LOD-1 every frame, and less often for <LOD-1 instead doing interpolation to set the positions. Perhaps the collision islands could track the highest LOD value for the associated entities and make all the entities use that value to control update rates while they are part of the island. I'd guess this sort of thing could coexist with the existing buffering system (if it is possible in the first place). I don't really expect this kind of feature to happen but I am curious about your thoughts on if anything like this might be viable or if you have any suggestions for reducing the overhead for objects that perhaps don't need the same level of simulation accuracy as others.
The only other thing I can think of that might work without deep changes in Bepu is to maintain one scene per discrete LOD and migrate objects between them as necessary. Special objects like terrain would need to be set up so they can have an Entity per scene that refers to common data as much as possible to minimize the memory costs and general overhead.
Thanks again for the use of this excellent physics engine,
I've been using buffered states with my game and I really like the feature. I would like to suggest perhaps the Entity could have a GetCurrentWorldTransform(out Matrix) that would automatically call down into either the Entity.WorldTransform or the BufferedStates.States.WorldTransform depending on the setting in Space.BufferedStates.Enabled. This would make it so people wouldn't have to refactor code to explicitly use (or not use) the buffered states while trying out different things; I had several bugs related to (my) oversights on the use of Entity.WorldTransform when buffering is enabled which made me think that perhaps this would be well suited for a wrapper at the Entity level. On a related note, it would be nice if the various properties that refer to Matrix objects had out/ref method versions to reduce the copy overhead (I haven't tested this myself but it seems to be the consensus that returning matrices and even Vector3's by out parameter is faster than a property and is worth doing when possible).
The other question bordering on a suggestion is related to the way the Space is updated. It would be really helpful if there was some way to continue to do an update at a fairly high rate but have some objects in the distance or otherwise less visible or less important save some cycles by reducing the amount of work done for them at a cost of simulation accuracy. Basically, LOD the physics in some way. I was wondering if there would perhaps be some way to make an Entity provide a heuristic 0..1 that would cause the object to be updated less often or less accurately (between some minimum and full rate as controlled by this heuristic). This is approaching the edge of my familiarity with Bepu's internals but I'm thinking one part of this sort of thing could be along the lines of a PositionUpdater that does the full update for LOD-1 every frame, and less often for <LOD-1 instead doing interpolation to set the positions. Perhaps the collision islands could track the highest LOD value for the associated entities and make all the entities use that value to control update rates while they are part of the island. I'd guess this sort of thing could coexist with the existing buffering system (if it is possible in the first place). I don't really expect this kind of feature to happen but I am curious about your thoughts on if anything like this might be viable or if you have any suggestions for reducing the overhead for objects that perhaps don't need the same level of simulation accuracy as others.
The only other thing I can think of that might work without deep changes in Bepu is to maintain one scene per discrete LOD and migrate objects between them as necessary. Special objects like terrain would need to be set up so they can have an Entity per scene that refers to common data as much as possible to minimize the memory costs and general overhead.
Thanks again for the use of this excellent physics engine,