Mythruna
March 29, 2024, 05:22:01 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Physics stuff...  (Read 6815 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« on: December 19, 2016, 01:38:36 AM »

This past week I've been writing a new physics engine from the ground up.  Both to incorporate a bunch of lessons learned as well as try to incorporate some fundamental missing design elements from the old ones.  I'm structuring this as another open source project but only time will tell if I ever release that way.

Anyway, as part of that, I made a little demo for me to test things.  It's kind of fun to play with for 20 seconds so I posted it for others to play also if they want to.

Here is the download landing page:
http://www.simsilica.com/sdm_downloads/physics-demo/

Here is where the thread starts on the JME forums:
https://hub.jmonkeyengine.org/t/december-2016-monthly-wip-screenshot-thread/37458/49?u=pspeed

From one of the posts on that other page:
Quote
WASD + mouse moves/looks. Left mouse fires big bullets, right mouse fires little bullets... space bar drops a bomb at the section of ground you are looking at. With no crosshair it's kind of find to guess.

The settings are currently optimized for stability so it's possible to get the balls to hang over the edges of the cubes and stuff if you hit them right. I'm also not sure why friction stops the small balls instantly on a rebound. It may be due to some other friction changes I made and it may just be a fact of counter rotation + high friction and low restitution (bounce).

Either way, I will always err on the side of stable versus chaotic. It works better for me and my game. (And hours of playing Skyrim makes me feel much better about my physics engine, anyway.)

Here are some screen shots of it in action:








Logged
Rayblon
Donators
Hero Member
***
Posts: 1861


Hmmm...


View Profile
« Reply #1 on: December 19, 2016, 03:57:40 AM »

Does this mean our blocky world is gonna have SPHERES?! Cheesy

Regardless of Mythruna's sphere status, I'll definitely need to make time to play around with this... tomorrow.

Can't wait. C:
Logged

pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #2 on: December 19, 2016, 04:24:02 AM »

Spheres are an easy way to test an physics engine because collisions are dirt-simple and really hard to get wrong.  Any bugs are that much more obvious.

So the first steps will be to get the whole framework of the physics engine worked out and properly partitioning space, etc..  Then I'll start moving the block world-level collisions and test those with the spheres (though by then they might be axis-oriented cubes).  After that I port the block object collision code.

Cell level collisions in Mythruna are treated like a combination of sphere and cube (for the collider, not the collidee).  At least that's how it's worked up until now.  So even if a single block visibly rotates, it's still axis aligned into whatever target it is colliding with. (If that's the world then it's axis-aligned with the world.)  This makes a bunch of things faster and easier and is a reasonable enough approximation.
Logged
Rayblon
Donators
Hero Member
***
Posts: 1861


Hmmm...


View Profile
« Reply #3 on: December 20, 2016, 10:31:22 PM »

I checked it out. I don't know how much you've already observed yourself, but I figure any feedback is good feedback.

So, from what I can tell immediately, yellow indicates that it is in motion, red indicates that it is active but not in motion, and teal means it is inactive. I noticed that on the corners & edges if you bounce it at just the right angle, it doesn't lose any velocity and goes bouncing up/backwards. It's hard to hit if you weren't looking for it, but...

Hitting the center of a certain face on a block seems to make it teleport to the top of the block/another face and bounce up without losing velocity, as well. I mostly observe it teleporting to the top, but it also will teleport to the right relative to the camera from those glitchy spots. Happens on edges too. Might be on every surface, actually. When you aim slightly above the 'equator' of a stationary sphere, it causes a super bounce too. I haven't been able to observe any porting though. Between two mobile balls, sometimes they don't deflect and they 'stick' and travel together for some time.


I assume the friction is really high on this demo, as everything feels 'sticky'. Balls are slow to roll off and lose velocity really fast. For testing states for physics objects, I suppose. Makes it a bit difficult to see velocity transfer in complex systems, though(ie dropping a ball in the middle of other balls should eject the outer balls). If you fire a sphere under a stationary sphere, you'll occasionally encounter a case where it remains stationary and begins rotating, thus never inactivating. I can't speak to whether it's permanent, but it's definitely looking that way. Inactive states seem to proc like crazy sometimes, and some balls will start flashing red over and over. Maybe there should be a cooldown between inactive procs? Even half a second or something. I've observed one occasion where a sphere turned inactive and began slowly crawling down a sphere while teal, then when it's about to fall, turn yellow and fall quickly.

Stacking about 4 or 5 bombs seems to make them have a stationary seizure. Hitting said tower yields no interesting effects thankfully. A larger tower causes the bombs to phase into eachother more and more while still vibrating like crazy, with the lower spheres constantly procing the inactive state without ever going inactive. Shooting something at it causes them to bulge out instead of restructure into a tower or something before falling. Larger spheres seem much more mobile than smaller spheres.


Hope that helped somewhat.
« Last Edit: December 20, 2016, 11:00:40 PM by Rayblon » Logged

Rayblon
Donators
Hero Member
***
Posts: 1861


Hmmm...


View Profile
« Reply #4 on: December 21, 2016, 09:10:20 AM »

I found another bug where when you fire a glancing blow at a vertical edge, it can stick on occasion. it'll roll along the edge and either stop and fall, or will proc the inactive state.
Logged

pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #5 on: December 27, 2016, 04:22:19 PM »

I've moved the releases over to bintray and there are new releases.

Latest release:
https://bintray.com/simsilica/demos/mphys-demo/1.2.0

F1 opens the help.  Tab opens the settings panel.

The big deal now is that objects are spatially "binned" and the engine only processes the active bins.  This was one of the necessary requirements that Mythruna physics will need.

As to your other comments, I won't go into detail but these settings were the ones I used when testing Mythruna objects and they will not necessarily look right with spheres.  They may not look right with Mythruna object either.  As per other discussion, I will always err on the side of stability.  As it stands with these settings, I was able to stack objects two high... which is sort of my minimum requirement in the end.  I'm ok if stacking crates more than two high doesn't work well but I'm not ok if you can't put items on a table.

Anyway, now you can tweak the settings all you like and discover why it's a difficult problem. Smiley  And in the end, tweaking it for spheres won't matter for block objects... so I will wait until I have block objects before I mess with that.

P.S.: At least one or two monkeys have shown an interest in seeing the source code... so this improves the likelihood that I will open source it... which also improves the likelihood that others will actually help fix any lingering math issues.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!