Hello all, I use box2d for several month. It works very nice for simple physics games. Now I consider integrate the box2d into my own engine, My target version is box2d-2.1.2, and here are my problems:
Action1:
I'm thinking about unify the spatial manager in my engine, since box2d use the dynamic-tree, I plan to reuse it for all of my game-object(actor). Basically, I want to create those physics object with b2Body, and let box2d manage them automatically. For those non-physics object, I would like add them manually into the dynamic-tree belongs to b2BroadPhase, and update the position and size of the AABB myself. My question are:
Question 1: is there any document introduce how to replace the b2DynamicTree?
Question 2: is it possible to hybrid b2Body and non-b2Body object in b2DynamicTree? (For those game-object, it doesn't need simulate with physics, but can be query by AABB tree).
For question 2, I look the box2d code, it seems like the proxy carry the userData will always cast into a fixture. So it seems like it is not possible to directly use b2DynamicTree in hybrid system. But if I can replace the tree (mention in question 1), at least I can rewrite the GetUserData and give a dummy fixture if it is a non-physics object.
Action2:
I plan to reuse the collision system of box2d in my engine. For those ground, physics-objects it works great, but when I try to use the collision system for non-physics objects, it gets problem. My first solution is create object with a b2Body, and set the b2Body as a sensor. This works fine, but it looks like box2d didn't check collision for static-static object. That will be a problem if I create a projectile (let's say a fireball) as a static sensor b2Body, and I want the fireball trigger the contact callback when it hit the ground --- which is a static b2Body. But it didn't successfully do that since fireball and ground pair are static-static. So My Question is
Queston:
Can box2d collision system manage collision for those static/user-control objects ???
And I have some solution below, which I'm not sure is it feasible:
Solution 1:
Change the box2d source code, add the new b2_customBody enum value. Create non-physics game object with b2Body, set as sensor, set the type to b2_customBody. In the b2Body::ShouldCollide() function, change the code to make it return true when b2_customBody vs any others.
After this, does the new type b2Body work correct with collision system? (the correct means, it works right with filter, group and contact listener...)
I'm not sure if these are clear? Any one can give me some suggestions or is there a better solution ?
Action1:
I'm thinking about unify the spatial manager in my engine, since box2d use the dynamic-tree, I plan to reuse it for all of my game-object(actor). Basically, I want to create those physics object with b2Body, and let box2d manage them automatically. For those non-physics object, I would like add them manually into the dynamic-tree belongs to b2BroadPhase, and update the position and size of the AABB myself. My question are:
Question 1: is there any document introduce how to replace the b2DynamicTree?
Question 2: is it possible to hybrid b2Body and non-b2Body object in b2DynamicTree? (For those game-object, it doesn't need simulate with physics, but can be query by AABB tree).
For question 2, I look the box2d code, it seems like the proxy carry the userData will always cast into a fixture. So it seems like it is not possible to directly use b2DynamicTree in hybrid system. But if I can replace the tree (mention in question 1), at least I can rewrite the GetUserData and give a dummy fixture if it is a non-physics object.
Action2:
I plan to reuse the collision system of box2d in my engine. For those ground, physics-objects it works great, but when I try to use the collision system for non-physics objects, it gets problem. My first solution is create object with a b2Body, and set the b2Body as a sensor. This works fine, but it looks like box2d didn't check collision for static-static object. That will be a problem if I create a projectile (let's say a fireball) as a static sensor b2Body, and I want the fireball trigger the contact callback when it hit the ground --- which is a static b2Body. But it didn't successfully do that since fireball and ground pair are static-static. So My Question is
Queston:
Can box2d collision system manage collision for those static/user-control objects ???
And I have some solution below, which I'm not sure is it feasible:
Solution 1:
Change the box2d source code, add the new b2_customBody enum value. Create non-physics game object with b2Body, set as sensor, set the type to b2_customBody. In the b2Body::ShouldCollide() function, change the code to make it return true when b2_customBody vs any others.
After this, does the new type b2Body work correct with collision system? (the correct means, it works right with filter, group and contact listener...)
I'm not sure if these are clear? Any one can give me some suggestions or is there a better solution ?