Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Physics Engine #46

Open
tre4got opened this issue Mar 30, 2015 · 2 comments
Open

Enhanced Physics Engine #46

tre4got opened this issue Mar 30, 2015 · 2 comments

Comments

@tre4got
Copy link
Contributor

tre4got commented Mar 30, 2015

Trevor Gotberg:

The current Physics Engine will no longer work with the updates to the Voxel Engine. A new design must be implemented requiring almost an entire re-write of the Physics Engine. This new design will include the following features:

  1. Dynamically create/destroy blocks in the "physics world" (each block in the world will be represented in the Physics Engine as an object with mass, velocity, acceleration, and position).
  2. Keep track of all the blocks in the world that are currently in motion and allow physics to be run ONLY on the moving objects.
  3. Basic collision detection and resolution.
  4. Exposed method to apply forces to specific blocks and set them in motion.

Analysis:
The creation and destruction of blocks can be done very much in parallel. A simple map for both of these functions is all that's required. Once all the blocks are created we'll mark the ones that are moving and add them to the active object list. The time it takes to create or destroy a new object can be considered constant.
work: 1(n)
span: 1
This is very scale-able.

Collision detection will have to use a stencil to observe the blocks surrounding it to determine if it has made any contact. This stencil will look at the blocks directly around the block in question to determine collisions and if any of those blocks are moving we'll have to run the physics on those block very carefully to make sure collisions are handled appropriately. These collisions can be run in parallel, so collision detection will be a map of stencils.
work: c(n) -> c is the number of collisions for the block in question, n is the number of moving objects
span: max(c) -> largest number of collisions would i guess in the worst case would be n-1 (it's colliding with every other block in the world)
Again this is very scale-able.

@tefu
Copy link
Contributor

tefu commented Mar 30, 2015

I'm not sure if it'd be best to have a mass on every block. You could probably get away with all blocks having the same mass. Let's Make A Voxel Engine somewhat covers this, if only abstractly.

Also, I realize I said a lot before regarding "chunks being only for the graphics", but the ChunkManager also carries functionality of "only update this section of the world when its changed". Since physics works on the entire world all the time, you might find that level of detail useful. For example, when someone changes a voxel in the world, you could notify the physics engine to check that section of the world.

@tre4got
Copy link
Contributor Author

tre4got commented Mar 31, 2015

You bring up a good point about mass. I was going to make mass variable just in case anyone had plans to elaborate on our textures. But if that's not the case we can use a constant mass.

When I talked with other members of our team we decided to pass blocks to the Physics Engine by using the Rectangular Prism object already in the repository rather than use the Chunks. However, I'd be more than willing to code it either way if it makes the Voxel Engine's job a little easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants