webots
webots copied to clipboard
Incorrect warping of in `Extrusion.proto`
Describe the Bug
-
Load world extrusion_bug.zip, it looks like:

-
Change last line of
spinefield from0 20 0to0 20 5. The extrusion warps as intended.
-
Set
zcoordinate back to 0. -
Change last line of
spinefield from0 20 0to5 20 0. The warping direction is correct, but the short and long edges have been swapped.
Appears to be the case in 2021b/2021a already and therefore other PROTO like Fence and CrashBarrier are also affected.
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.
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.
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:

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:

I would suggest to continue the investigation, based on this debug proto, and display more axes if needed.
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