Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

252 Neutral

About d07RiV

Personal Information

  • Industry Role
    3D Animator
  • Interests
  1. d07RiV

    Add floor in skybox

    I think you meant to post in the graphics subforum?
  2. d07RiV

    Modeling restitution

    I'm a little lost in the terminology here. Which model is sequential and which is simulatenous? Does simulatenous imply that you try to solve all contacts at the same time, or is it the same as iterating through them multiple times? I also found an old discussion here https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=&f=4&t=1584 Jan Bender claims that the method in his paper handles newton cradle correctly, but the description of how it handles collisions seems identical to the classic constraint solver.
  3. d07RiV

    Improving sleep system

    So it looks like another problem not worth trying to solve I guess. Although I guess I could do a partial solution, where a body at least N edges away from other moving bodies (N being the number of resolution steps) is safe to leave sleeping. Otherwise I would have to wake up bodies based on the velocities in the middle of the resolution step, which doesn't seem to work well at all. I'm using collision algorithms from Erin Catto's paper I believe, so I do have some caching like saving axis/features for hull-hull collisions in order to resolve the next step faster.
  4. d07RiV

    Get Angle of 3D Line and Rotate Polygon With Result

    I would avoid working with euler angles unless you absolutely must. If you just need to rotate a model such that it's, say, Y axis is aligned with a given line, you can build a basis from that line (basically, come up with X and Z axes so that everything is perpendicular) and do a simple transformation that way. Then if you need to rotate the mesh to face a different direction, you can also ensure that the new basis is as similar to the previous one as possible.
  5. d07RiV

    Improving sleep system

    By islands here you mean any set of touching bodies? That seems like it would work similarly to my algorithm that propagates sleep times. It doesn't work well in the dominos case I mentioned - it can't put the tiles at the far end of the chain to sleep because everything is technically one island. It's also a part of the web demo I put together earlier: https://physics.rivsoft.net/Dominos - sleeping bodies can be shown with a checkbox on the right. Don't mind that I accidentally wake up extra bodies during broadphase, don't think it's the main issue here.
  6. d07RiV

    Improving sleep system

    Well I tried what I said, now it can never put objects to sleep, because due to gravity, at some point during the resolution step an body's speed will exceed the threshold and it will wake up every adjacent body.
  7. d07RiV

    Improving sleep system

    I'm trying to incorporate a sleep system into my engine. I've tried several approaches so far, and they all had significant issues. The putting objects to sleep part is simple enough, just detect when they stop moving for a certain amount of time and flag them as sleeping, and skip contacts between two sleeping objects. The hard part is when to wake them up. Obviously, waking up any object in contact with an awake object is not going to work, because they'd just keep waking each other up indefinitely. Instead, I made them set each other's "sleep" time to the minimum of the two, so eventually the whole island goes to sleep. This works pretty well, but in some cases it's pretty useless - for instance, if I make a very long chain of dominos and start collapsing it, then the end of the collapsed chain will always keep the whole thing awake even though 90% of it isn't moving, so eventually the simulation slows down significantly. I've checked some simpler engines and another approach I found was to only wake up objects when the awake object in the pair exceeds certain velocity. However, this means that sometimes the solver will try to solve contacts between a sleeping and awake object, so I made it treat sleeping objects as stationary (infinite mass/momentum). This fixed the domino chain, but caused a much bigger issue in other simulations. Taking the newton cradle example (or any other scene where something collides into a group of resting objects), it simply can't propagate impulses through the chain of stationary balls - if the third ball in chain never moves (since the fourth ball is blocking it), it will never wake up the fourth ball. It seems that the waking up checks need to be repeated every time a body's velocity changes during contact resolution. This means an object has to be waken up, it's contacts with adjacent sleeping bodies need to be re-activated and initialized (which involves collision checks and some additional computations) and added to the active contact list for subsequent resolution steps. It sounds like it could work, but I'm not sure if I like the idea of mixing the collision and resolution stages. Am I on the right track here?
  8. d07RiV

    Modeling restitution

    It's definitely possible to simulate with some methods. In my old school project 2D solver it worked perfectly, because it handled contacts one at a time, so it took multiple frames to propagate the impulse. But that solver has tons of other limitations. I was specifically asking about more general case solvers that can handle complex scenes. If all contacts are resolved simultaneously (iteratively or not), then it seems there is no way to specify which particular solution you're looking for. Oh well, thanks anyway.
  9. d07RiV

    Modeling restitution

    Ah well, so most engines just ignore this and move on? Unless some system can figure out the propagation graph, but idk if that's possible to do for a generic complex scene. Pool ball worked fine for me though, the two balls roll away at equal angles and the third ball rolls backwards slightly (or even forward, depending on friction).
  10. d07RiV

    3D Manifold Collision Response

    PreStep calculates the "inverse mass" term - basically by how much the relative velocity at contact changes if you apply a unit impulse there. \((JWJ^T)^{-1}\) term (huh, what happened to tex math?). It is done there so you don't have to calculate it in the ApplyImpulse step, which allows you to call it multiple times at less cost. It also applies accumulated impulses from the previous step, which makes the system more stable. Without those, you won't be able to make things like a stack of boxes without it falling apart.
  11. d07RiV

    Modeling restitution

    I don't have a way to visualize separate collision steps (rendering is completely detached from the physics engine atm), but I went through it in the debugger and it takes several iterations (like 4, depending on which order it decides to resolve everything in) to move everything nicely from the first two balls to the last two as expected, but then it starts going back and messing everything up - basically whenever it runs across a contact in which the balls are already separating (from restitution), it tries to adjust velocities back. That gap trick worked, but now after the collision the balls aren't vertical anymore, so they start swinging back slowly, and after several swings it doesn't look so good anymore.
  12. d07RiV

    Modeling restitution

    How would you tell which way it should travel? I looked up some articles and they seem to suggest topological sort in the direction of gravity, so bottom objects resolve first, but in a general case we don't know where the impulses are coming from - for all we know it could be both ways. I tried tweaking my solver to introduce restitution at different points, I can get it to propagate the impulses all the way through the chain, but then it goes back and tries to reduce the lambdas because it thinks they're too high (since balls are moving apart). Maybe there's some way to do it properly, by dynamically updating a lower limit on lambdas or something?
  13. d07RiV

    Modeling restitution

    It actually is propagating immediately, since there are 8 velocity resolution steps currently. I think that's actually *why* it's not working, because if the velocity can propagate between steps, then the initial velocity used to calculate bias is no longer correct. I need a way to update bias inbetween steps, to account for propagated velocities, which should also force balls to bounce apart. If I reduce it to just one step, it starts working as expected, at least for a smaller number of balls (order starts to matter). I do have that "slop" parameter, except it works the opposite way and creates contacts when objects are within a certain distance.
  14. d07RiV

    Modeling restitution

    I've dug up my old JS physics engine and am trying to make some scenes to test its capabilities. One problem I ran across is that restitution is not modeled correctly. In particular, Newton Cradle does not work as expected and it randomly bounces the balls around, as seen here: https://physics.rivsoft.net/Newton (controls are RMB to rotate, wheel to zoom). As suggested by multiple sources, I'm adding relative normal velocity times restitution to the bias term (for 1D Jacobian), and using velocity at the start of the step for this. However, for obvious reasons this doesn't work if I have multiple velocity resolution steps. How am I supposed to update the bias between steps in order to correctly model restitution?
  15. d07RiV

    Mirror hierarchy in local space

    It is definitely the correct way of mirroring a quaternion. If you think of it as [sin(w/2)*axis,cos(w/2)], then you see that inverting the X component effectively mirrors the axis, and inverting W inverts the angle.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!