cfry / dde

Dexter Development Environment
Other
44 stars 25 forks source link

Added the ability to update colliders using the updateCollider function #104

Closed lmarsbrown closed 3 months ago

lmarsbrown commented 3 months ago

Added physicsObject to userdata Improved lighting

cfry commented 3 months ago

Summary: several problems. Details below:

... and the bad news ..................

Furthermore, the color of the object is screwed up. There's one color for the orig box and different color for the "extensions" to the shape. Very strange. Possibly because you're making a new mesh for the object but that new mesh is not getting the color property from the old mesh. mesh.material.color is where its stored.

The behavior appears to be that there is a tiny area that you can click on to get the callback fn for the click to trigger. I guess this is a tiny volume in the center of the cube you're clicking on, but even clicking there is unreliable, but more probabilistically likely than clicking other places on the surface of a cube. This use to be more reliable (before Phys Objs).

I have looked very carefully at the supporting code and, comparing it to the "simple example" at //patterned after simple example at: https://github.com/markuslerner/THREE.Interactive/blob/master/examples/simple.html

there is some init code in Simulate.js, method: static init_interaction_manager() with the callback being defined in: static interaction_add(object3d)

I've stepped thru this code and when a click actually gets fired, stepping thru it all looks good, but that's rare.

On Wed, Jun 5, 2024 at 7:15 PM lmarsbrown @.***> wrote:

Added physicsObject to userdata Improved lighting

You can view, comment on, or merge this pull request online at:

https://github.com/cfry/dde/pull/104 Commit Summary

File Changes

(3 files https://github.com/cfry/dde/pull/104/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/cfry/dde/pull/104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJBG7LE4YEY2FVIX6WCRZTZF6LXNAVCNFSM6AAAAABI3UBL56VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTMOJXGUZTQMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cfry commented 3 months ago

simulateRate has no effect on sim speed:

Simulate.simulateRate = 1.0 new Job({ name: "my_job", do_list: [ Dexter.move_all_joints(10, 20, 30), Dexter.move_all_joints(0, 0, 0) ] }) Job.my_job.start() takes about 3 seconds

On Thu, Jun 6, 2024 at 1:29 AM Christopher Fry @.***> wrote:

Summary: several problems. Details below:

  • No merge conflicts.

  • I pulled this into my code.

  • mesh.userData.physObj works!

  • Your new lighting is much better. My "white" boxes now look white and the table is lighter. Also helps will all other colors. Nice.

  • Your new setting of mesh.userData.physObj working great.

... and the bad news ..................

  • Bug: In Simulate.js, static do_animation_loop() lines 628 and 639, there are references to SimObj.refresh Both should be replaced with SimBuild.refresh I couldn't find my email talking about this so maybe I made the mistake. Yes there is a SimObj.refresh, and it is correctly referenced in Simulate.js in the method static init_simulation() BUT it does something different than SimBuild.refresh and that difference is breaking my code so please switch. Sorry, this is admittedly confusing.

  • I patched my local copy of Simulate.js with the above fix and it worked, BUT I had to fix SimBuild to print out To make a new object3d in the simulator pane, click the Make Object button. only once because other wise it filled the output pane with this every frame.

  • bug: moving an object in positive x still moves it negative (right) and moving an object in positive y, still moves it negative (back) just like it did in your last pull release, but unlike my pre_phys_obj code.

  • bug: the collider box around an object is not growing when I make the shape bigger. (Now on SimBuild dialog, there's a "show_all" select box, which now has on it: "show_colliders" and "hide_colliders" to make it easy to turn on and off the outlines of the colliders, calling your code (works great).

Furthermore, the color of the object is screwed up. There's one color for the orig box and different color for the "extensions" to the shape. Very strange. Possibly because you're making a new mesh for the object but that new mesh is not getting the color property from the old mesh. mesh.material.color is where its stored.

  • Bug: The Interaction manager is operating very unreliably. What's suppose to happen is that when you click on an object in the sim pane, that object is supposed to become the object is supposed to be edited in the SimBuild dialog. If the box's color is "single_color" (as opposed to multi-color), you will also see the color of the whole box turn to yellow.

The behavior appears to be that there is a tiny area that you can click on to get the callback fn for the click to trigger. I guess this is a tiny volume in the center of the cube you're clicking on, but even clicking there is unreliable, but more probabilistically likely than clicking other places on the surface of a cube. This use to be more reliable (before Phys Objs).

I have looked very carefully at the supporting code and, comparing it to the "simple example" at //patterned after simple example at: https://github.com/markuslerner/THREE.Interactive/blob/master/examples/simple.html

there is some init code in Simulate.js, method: static init_interaction_manager() with the callback being defined in: static interaction_add(object3d)

I've stepped thru this code and when a click actually gets fired, stepping thru it all looks good, but that's rare.

  • I am anticipating one more bug, but its too hard to even test this with the above problems. Now, in the SimBuild dialog, I have the ability to set the mass of an object. The only thing I can think of doing is literally setting the mass in the corresponding PhysObj (in simobj.js : static set_mass(object3d_or_name, mass_in_grams) { let object3d = SimObj.get_object3d(object3d_or_name) let a_po = this.get_physics_object(object3d) let mass_in_kg = mass_in_grams / 1000 a_po.mass = mass_in_kg } It won't surprise me if this fails as I'm guessing Ammo won't notice the change in this variable and we'd have to call some sort of "update" method, or perhaps even destroy the PhysObj and create a new one, passing in the new mass. But if that's the case, beware of the "material.color" problem mentioned above.

    I have pushed my changes to master with the commit message: "fix to SimBuild to print out To make a new object just once, and the fix of replacing SimObj.refresh() to SimBuild.refresh()" That last item is very minor in Simulate.js (see above for that change.) Note: I try not to modify Simulate.js but needed to to get as far as I did tonight.

On Wed, Jun 5, 2024 at 7:15 PM lmarsbrown @.***> wrote:

Added physicsObject to userdata Improved lighting

You can view, comment on, or merge this pull request online at:

https://github.com/cfry/dde/pull/104 Commit Summary

File Changes

(3 files https://github.com/cfry/dde/pull/104/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/cfry/dde/pull/104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJBG7LE4YEY2FVIX6WCRZTZF6LXNAVCNFSM6AAAAABI3UBL56VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTMOJXGUZTQMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cfry commented 3 months ago

Last email was ill-formed, Here's something better. Eval: new Job({ name: "my_job", do_list: [ Dexter.move_all_joints(10, 20, 30), Dexter.move_all_joints(0, 0, 0) ] }) Eval: Simulate.simulateRate = 1.0 Eval: Job.my_job.start() takes about 4 seconds Eval: Simulate.simulateRate = 2.0 Eval: Job.my_job.start() takes about 4 seconds but should have taken 2 seconds, right? Eval: Simulate.simulateRate = 0.5 Eval: Job.my_job.start() takes about 4 seconds

On Thu, Jun 6, 2024 at 4:00 PM Christopher Fry @.***> wrote:

simulateRate has no effect on sim speed:

Simulate.simulateRate = 1.0 new Job({ name: "my_job", do_list: [ Dexter.move_all_joints(10, 20, 30), Dexter.move_all_joints(0, 0, 0) ] }) Job.my_job.start() takes about 3 seconds

On Thu, Jun 6, 2024 at 1:29 AM Christopher Fry @.***> wrote:

Summary: several problems. Details below:

  • No merge conflicts.

  • I pulled this into my code.

  • mesh.userData.physObj works!

  • Your new lighting is much better. My "white" boxes now look white and the table is lighter. Also helps will all other colors. Nice.

  • Your new setting of mesh.userData.physObj working great.

... and the bad news ..................

  • Bug: In Simulate.js, static do_animation_loop() lines 628 and 639, there are references to SimObj.refresh Both should be replaced with SimBuild.refresh I couldn't find my email talking about this so maybe I made the mistake. Yes there is a SimObj.refresh, and it is correctly referenced in Simulate.js in the method static init_simulation() BUT it does something different than SimBuild.refresh and that difference is breaking my code so please switch. Sorry, this is admittedly confusing.

  • I patched my local copy of Simulate.js with the above fix and it worked, BUT I had to fix SimBuild to print out To make a new object3d in the simulator pane, click the Make Object button. only once because other wise it filled the output pane with this every frame.

  • bug: moving an object in positive x still moves it negative (right) and moving an object in positive y, still moves it negative (back) just like it did in your last pull release, but unlike my pre_phys_obj code.

  • bug: the collider box around an object is not growing when I make the shape bigger. (Now on SimBuild dialog, there's a "show_all" select box, which now has on it: "show_colliders" and "hide_colliders" to make it easy to turn on and off the outlines of the colliders, calling your code (works great).

Furthermore, the color of the object is screwed up. There's one color for the orig box and different color for the "extensions" to the shape. Very strange. Possibly because you're making a new mesh for the object but that new mesh is not getting the color property from the old mesh. mesh.material.color is where its stored.

  • Bug: The Interaction manager is operating very unreliably. What's suppose to happen is that when you click on an object in the sim pane, that object is supposed to become the object is supposed to be edited in the SimBuild dialog. If the box's color is "single_color" (as opposed to multi-color), you will also see the color of the whole box turn to yellow.

The behavior appears to be that there is a tiny area that you can click on to get the callback fn for the click to trigger. I guess this is a tiny volume in the center of the cube you're clicking on, but even clicking there is unreliable, but more probabilistically likely than clicking other places on the surface of a cube. This use to be more reliable (before Phys Objs).

I have looked very carefully at the supporting code and, comparing it to the "simple example" at //patterned after simple example at: https://github.com/markuslerner/THREE.Interactive/blob/master/examples/simple.html

there is some init code in Simulate.js, method: static init_interaction_manager() with the callback being defined in: static interaction_add(object3d)

I've stepped thru this code and when a click actually gets fired, stepping thru it all looks good, but that's rare.

  • I am anticipating one more bug, but its too hard to even test this with the above problems. Now, in the SimBuild dialog, I have the ability to set the mass of an object. The only thing I can think of doing is literally setting the mass in the corresponding PhysObj (in simobj.js : static set_mass(object3d_or_name, mass_in_grams) { let object3d = SimObj.get_object3d(object3d_or_name) let a_po = this.get_physics_object(object3d) let mass_in_kg = mass_in_grams / 1000 a_po.mass = mass_in_kg } It won't surprise me if this fails as I'm guessing Ammo won't notice the change in this variable and we'd have to call some sort of "update" method, or perhaps even destroy the PhysObj and create a new one, passing in the new mass. But if that's the case, beware of the "material.color" problem mentioned above.

    I have pushed my changes to master with the commit message: "fix to SimBuild to print out To make a new object just once, and the fix of replacing SimObj.refresh() to SimBuild.refresh()" That last item is very minor in Simulate.js (see above for that change.) Note: I try not to modify Simulate.js but needed to to get as far as I did tonight.

On Wed, Jun 5, 2024 at 7:15 PM lmarsbrown @.***> wrote:

Added physicsObject to userdata Improved lighting

You can view, comment on, or merge this pull request online at:

https://github.com/cfry/dde/pull/104 Commit Summary

File Changes

(3 files https://github.com/cfry/dde/pull/104/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/cfry/dde/pull/104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJBG7LE4YEY2FVIX6WCRZTZF6LXNAVCNFSM6AAAAABI3UBL56VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTMOJXGUZTQMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

lmarsbrown commented 3 months ago

The variable to adjust the speed is called Simulate.simulationRate. Forgot about the helper mesh; I will make that update. Not sure about the reversed axes. The simbuild meshes shouldn't be affected by physics object so its unclear what is causing that. It might be related to changes made to make simbuild physicsObject compatible.

What do you mean by the "extensions" to the shape?

cfry commented 3 months ago

On Thu, Jun 6, 2024 at 5:11 PM lmarsbrown @.***> wrote:

The variable to adjust the speed is called Simulate.simulationRate.

Whoops! my mistake.

Forgot about the helper mesh; I will make that update.

Not sure about the reversed axes. The simbuild meshes shouldn't be affected by physics object so its unclear what is causing that. It might be related to changes made to make simbuild physicsObject compatible.

Yeah, this looks like a tough one. Maybe we should rope in James N.

What do you mean by the "extensions" to the shape?

If I create a cube, and turn on colliders showing, I see a nice collider bounding the cube. (easier to if the cube is NOT multi-color) But when I change the cube's shape, like just makes the y axis longer, the collider shape does not change, it remains the same (cube) so collisions will be off and the color of the color of the "new material added" is all screwed up.

I've got a meeting now for the next hour. Will work on this code after that.

— Reply to this email directly, view it on GitHub https://github.com/cfry/dde/pull/104#issuecomment-2153414707, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJBG7JZI4ZMPXDM64YWUE3ZGDF6NAVCNFSM6AAAAABI3UBL56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJTGQYTINZQG4 . You are receiving this because you modified the open/close state.Message ID: @.***>