[v1]Accelerating StaticMesh creation
Posted: Sun May 24, 2020 10:07 pm
Hi Norbo!
Lately I've been abusing a bit of StaticMesh in bepu v1. It has accelerated a lot the execution in runtime while making the load slower. I had no problem with it, until I've recently realized that sometimes I need a very fast StaticMesh creation. The game is a JRPG and I want the transitions to battle to be as fast as possible.
I've been profiling and I've found that most of the time is lost when calling Reconstruct at MeshBoundingBoxTree when creating the StaticMesh. If I'm not wrong, it is a tree created to accelerate collision detections.
What I'd like to do is to avoid creating the StaticMesh acceleration tree every time, taking advantage of the fact that the maps that are reloaded very often are usually the same map for a long period of time. I'd like to save somehow that tree and reuse when creating the mesh again.
My question is if it's possible, and which would be the safest/easiest way to acomplish that.
What I've thought so far is getting a reference the MeshBoundingBoxTree once it's constructed the first time, save that reference and reuse it later by passing it as a new parameters for a new constructor of a StaticMesh. As I'm holding that reference, it's supposed not to be collected thus, as long as the mesh is the same, the acceleration tree would be also the same, despite the fact that the physics Space will be destroyed once the battle is over, isn't it?
However I don't know if this is possible, or if there is a better solution.
Thanks!
Kak
Lately I've been abusing a bit of StaticMesh in bepu v1. It has accelerated a lot the execution in runtime while making the load slower. I had no problem with it, until I've recently realized that sometimes I need a very fast StaticMesh creation. The game is a JRPG and I want the transitions to battle to be as fast as possible.
I've been profiling and I've found that most of the time is lost when calling Reconstruct at MeshBoundingBoxTree when creating the StaticMesh. If I'm not wrong, it is a tree created to accelerate collision detections.
What I'd like to do is to avoid creating the StaticMesh acceleration tree every time, taking advantage of the fact that the maps that are reloaded very often are usually the same map for a long period of time. I'd like to save somehow that tree and reuse when creating the mesh again.
My question is if it's possible, and which would be the safest/easiest way to acomplish that.
What I've thought so far is getting a reference the MeshBoundingBoxTree once it's constructed the first time, save that reference and reuse it later by passing it as a new parameters for a new constructor of a StaticMesh. As I'm holding that reference, it's supposed not to be collected thus, as long as the mesh is the same, the acceleration tree would be also the same, despite the fact that the physics Space will be destroyed once the battle is over, isn't it?
However I don't know if this is possible, or if there is a better solution.
Thanks!
Kak