-
I was first trying something in Unity and thought I could shave off some overhead by using box2d directly, but I'm currently seeing the opposite. In Unity I'm doing the same thing except using Unity's methods. New GameObject, Add Component of BoxCollider2D, which accepts a previously defined BoxCollider2D. In Unity this executes in about 50 ms. In the standalone box2d using the latest code, this takes about 1.2 seconds. where 1 second of it is the b2CreatePolygonShape() and the other 0.2 is b2CreateBody() Why is Unity so much faster with the creation times? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It might be that the Unity API uses width whereas the Box2D API uses half-widths. This could lead to many shapes overlapping, creating and n-squared cost. |
Beta Was this translation helpful? Give feedback.
Okay, I tested your code. It does take quite a while in the debug build. This is due to heavy validation. In the release build it takes ~7ms. See
BOX2D_VALIDATE
andB2_VALIDATE
.