jit.phys tutorial video, question

Oct 4, 2012 at 2:31pm

jit.phys tutorial video, question

Hi
I am following the excellent jit.phys video tutorial

http://cycling74.com/2012/09/17/introduction-to-jit-phys-part-1/

and have successfully created a bouncing ball, gravity and a moving floor (or ‘paddle’)

and have encountered a minor issue. As part of a larger patch, wherein the user (via force-sensing resistor -> gui slider) can hit a ball into the air by moving the onscreen paddle, occasionally the ball will pass through the floor, especially when the floor is moved very quickly. I have attached a small patch below to demonstrate (my ‘net computer has issues with jit.phys, so apologies for the non-compressed file).

Thanks for any suggestions

Brendan

#64615
Oct 4, 2012 at 2:54pm

hi brendan. you need to set @kinematic 1 on your phys.body “paddle”

this tells the rigid-body that it’s going to have it’s position/rotation set based on your input, rather than based on the forces in the world.
this should fix your problem, but let me know if not.

#233120
Oct 4, 2012 at 3:23pm

Excellent Robert, works as you say.

Thanks for the speedy reply too.

Brendan

#233121
Oct 6, 2012 at 4:05pm

……it DID work; I did some quick research before I started tweaking, in order to get the desired functionality and……the problem returned.

I need the ball to have some real-world weight, so I have set the following parameters: @mass 3 @restitution 0.8, and the world gravity is quite extreme (-500!). And now, as before, if the paddle accelerates past the ball, it will pass through it. Please see the attached patch and image.

Brendan

[attachment=205343,4499]

Attachments:
  1. bounceerror.PNG
#233122
Oct 6, 2012 at 4:41pm

hi,
you could use “fixedtimestep”, “maxsubsteps ” parameters on “jit.phys.world” to increase the resolution of the simulation
Rob Ramirez wrote a very useful note
http://cycling74.com/forums/topic.php?id=38167
hope that it can help you
mathieu

#233123
Oct 6, 2012 at 7:45pm

Thanks mathieu, I’ll read more on those two parameters; obviously there’s a lot more going on than I understand – loads of experience with Max but none at all with Jitter; your suggested link was very helpful too.

Brendan

edit
not too sure what my own fps rate is, but I changed the qmetro from @interval 60Hz, to 10ms (any higher and the problem returns) and set the maxsubsteps parm to 2; this appears to have resolved the issue. I understand this is my own lack of knowledge, not a Jitter quirk. : )

#233124
Oct 8, 2012 at 7:39pm

i’ll see if i can explain this better.

ideally, you want your physics engine update frequency (fixedtimestep) to match your render FPS.
if you use jit.window with @sync 1 (the default value), and a very fast qmetro (eg 1), your render rate will sync to your display refresh rate (usually around 60). this plays well with the default phys.world @fixedtimestep of 60.

however, if you run your render fps at 30, you need to adjust your physics hz as well, otherwise the physics simulation will lose time (and look like it’s running in slow-motion). easiest solution may be to set @fixedtimestep = 30. this will fix the slow-motion effect, however 30 fps is not the ideal hz for the physics simulation (although it may be fine for many patches). the alternative is to increase @maxsubsteps to 2 (allowing the physics simulation to take 2 substeps for every render frame: 60 / 30 = 2)

more complicated physics scenes may require a faster update frequency to accurately simulate the objects. so you may wish to increase the fixedtimestep to something like 120 or 240, and the max substeps to either 120/30 = 4 or 240/30 = 8.

of course with any computer simulation, greater accuracy requires more cpu.

hope this helps.

#233125
Oct 8, 2012 at 8:55pm

Wow. Thank you so much for this explanation. Crystal clear.

Brendan

#233126

You must be logged in to reply to this topic.