SPC-Some-Polish-Coders / PopHead

2D, zombie, action game made from scratch in C++
MIT License
116 stars 21 forks source link

Add circle bodies #443

Closed PiotrGardocki closed 4 years ago

PiotrGardocki commented 4 years ago
meyerzinn commented 4 years ago

Are you considering refactoring the current kinematics systems to use some sort of union component instead of storing a rectangle, to enable all of these different collision types?

If you are interested in adding more complex kinematics (i.e., polygons), what are the benefits to writing your own solver as opposed to integrating something like box2d or chipmunk2d?

PiotrGardocki commented 4 years ago

For now we do not plan to add polygons to the game. Rectangles and circles should be enough for our gameplay. I think I already found a solution to optimize current collisions system. Details are in comment here: #444

External physics library would be a solution to some problems, but then we would need to integrate it with our ECS library. I think libraries you mentioned are using their own storage for bodies, so connecting them to the Entt components pools would not be worth the effort.

Czapa10 commented 4 years ago

We're not gonna integrate any kind of physics engine to our game. Physics engine libary like box2D simulates physics realistically. In our game we don't want physics to be realistic. We want physics interactions solve the gameplay problems which we have and realistic physics engine doesn't solve these problems. That's why we don't use it.

Czapa10 commented 4 years ago

@20zinnm @PiotrGardocki Making union component is not the right solution.

Option 1: We make separate components: RectangleKinematicCollisionBody, CircleKinematicCollisionBody.

Option 2: We make component like RigidBody which stores things like mass, staticallyMovedUp itd. And we have another components like: RectCollisionShape, CircleCollisionShape which store collision geometry.

Later we can also make circle collision shapes for static collision body but for now it's not neccessary.

meyerzinn commented 4 years ago

@Czapa10 That's fair. I think Option 2 is how most other "physics" engines work, where there's a rigidbody that stores general information and a flag that indicates what geometry to use.