cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.28k stars 1.71k forks source link

Incorrect warping of in `Extrusion.proto` #3656

Open ad-daniel opened 3 years ago

ad-daniel commented 3 years ago

Describe the Bug

  1. Load world extrusion_bug.zip, it looks like: a

  2. Change last line of spine field from 0 20 0 to 0 20 5. The extrusion warps as intended. b

  3. Set z coordinate back to 0.

  4. Change last line of spine field from 0 20 0 to 5 20 0. The warping direction is correct, but the short and long edges have been swapped. c

Appears to be the case in 2021b/2021a already and therefore other PROTO like Fence and CrashBarrier are also affected.

joachimhgg commented 2 years ago

Extrusion_with_comments.zip

I commented the proto to verify that we implemented all the conditions based on https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/geometry3D.html#Extrusion.

joachimhgg commented 2 years ago

2021_11_24_0g4_Kleki 1 = line of spine field : 0 20 0 2 = line of spine field : 5 20 0 3 = line of spine field : 0 20 5

When reproducing the 3 cases in Blender, we got the same behavior.

omichel commented 2 years ago

I wrote a debug proto allowing to display the axes for each spine point of the extrusion and found that the axes are not orthonormal, should be fixed:

test

Then, when changing the last spin value from 0 20 0 to 0.0001 20 0, the axes are swapped, whereas they should remain about the same: test_1

I would suggest to continue the investigation, based on this debug proto, and display more axes if needed.

omichel commented 2 years ago

Also when displaying the orientation values for the X-axis, something looks wrong as not all orientations are defined:

if (orientation[i] !== undefined) {
  console.log('orientation[' + i + ']: ' + orientation[i].x + ' ' + orientation[i].y + ' ' + orientation[i].z);
  point = wbrotation.rotateVector3ByRotation(orientation[i], point);
} else
  console.log('orientation[' + i + '] undefined');                

gives:

INFO: 'ExtrusionShape.proto': JavaScript output: orientation[0]: 0 0 1
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[1]: 0 0.25 0.75
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[2]: 0 0.5 0.5
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[3]: 0 0.75 0.25
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[4] undefined
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[5] undefined
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[6] undefined
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[7] undefined
INFO: 'ExtrusionShape.proto': JavaScript output: orientation[8] undefined