[Opensim-users] ubODE vs. Bullet (Ferd Frederix)

Fred Beckhusen fred.b at mitsi.com
Mon May 1 14:45:42 UTC 2017


Tom, I think this is a difference in implementation details.  To me, 
Bullet actually gets it correct.

Your script is setting Hover height to go up and down. It is 
effectively  llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, HovHeightBase 
+= .02 ); each click Up and -= 0.02 on Down, while starting from a 
negative value.   Zero is water height (typically 20 meters).    Water 
height can range from 0 to +100 in a sim.

The problem is that VEHICLE_HOVER_HEIGHT is for use only above 
ground.    It is not defined in LSL by Second Life for use with negative 
numbers, with additional proof of this is that zero (water height) 
disables it entirely.   So it is implementation specific.  I would chalk 
this up as expected behavior in Bullet.

Try adding a float Z variable to your VEHICLE_LINEAR_MOTOR_DIRECTION and 
add or subtract a small amount from the Z (up)  axis.

Your axis seems suspicious. In vehicles, X is forward/back, Y is L-R, 
and Z is up.  Your script right and left controls are setting 
VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 5.0>, which is mucking around 
with Z (Up).  Sounds correct for a prim that rotates around Z, but not 
for a vehicle.  I could be wrong here. There may be a 
VEHICLE_REFERENCE_FRAME set in your script elsewhere that is overriding 
the reference axis, so be wary of it.

Also, take a look at the function llWater(), and think about doing this:

vector water = llWater(ZERO_VECTOR);
HovHeightBase += water.z - 20;

This will handle sims where water is at a different level.

regards and good luck:\
   Ferd Frederix/Fred Beckhusen

On 2017-05-01 5:20 AM, opensim-users-request at opensimulator.org wrote:
> Send Opensim-users mailing list submissions to
> 	opensim-users at opensimulator.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-users
> or, via email, send a message with subject or body 'help' to
> 	opensim-users-request at opensimulator.org
>
> You can reach the person managing the list at
> 	opensim-users-owner at opensimulator.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Opensim-users digest..."
>
>
> Today's Topics:
>
>     1. ubODE vs. Bullet (tringate at gmail.com)
>     2. Re: ubODE vs. Bullet (AJLDuarte)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 30 Apr 2017 23:27:37 -0400
> From: <tringate at gmail.com>
> To: "OS-Opensim Users" <opensim-users at opensimulator.org>
> Subject: [Opensim-users] ubODE vs. Bullet
> Message-ID: <65ED585961044A12B8C19EA5984238E3 at TomsDesktop>
> Content-Type: text/plain; charset="utf-8"
>
> I am working on a script for a submarine and am having issues with it working fine in ubode but will not dive or surface in Bullet physics.
>
> Here are the primary items that are involved with the physics.
>
> This is the initial settings the object is set with.
>
> set_engine(){
>      llSetVehicleType(VEHICLE_TYPE_BOAT);
>      llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.5);
>      llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1);
>      llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
>      llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
>      llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1, 1, 1>);
>      llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
>      llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0);
>      llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.5);
>      llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.2);
>      llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <0.1, 0.1, 0.1>);
>      llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5);
>      llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.0);
>      llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0.0); // set ball at water surface
>      llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0.5 );
>      llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 1.0 );
> }
>
> These are the controls and they work fine in ubODE, but CONTROL_UP and CONTROL_DOWN do nothing in Bullet.
>
> control(key id, integer level, integer edge)
>      {
>          float    gForwardThrust; // variable for forward thrust
>          float    gReverseThrust = -1.5; // reverse thrust backup speed
>          if(level & CONTROL_FWD)
>          {
>              Swimming();
>              gForwardThrust = 3; // normal forward speed
>              vTarget = llGetPos(); // get our current position
>              // if near region edge, slow down
>              if (vTarget.x > xlimit || vTarget.x < gGuard || vTarget.y > ylimit || vTarget.y < gGuard)
>              {
>                  if (vTarget.x > xlimit) vTarget.x = xlimit;
>                  if (vTarget.x < gGuard) vTarget.x = gGuard;
>                  if (vTarget.y > xlimit) vTarget.y = ylimit;
>                  if (vTarget.y < gGuard) vTarget.y = gGuard;
>                  gForwardThrust = .3; // slow us down
>                  llWhisper(0, "Approaching sim edge, drive away...");
>              }
>              if ( vTarget.z < (llGround ( ZERO_VECTOR ) + 0.35) )
>              {    // too shallow and going to collide with land
>                  gForwardThrust = .05; // slow us down
>                  llWhisper(0, "Too shallow, drive away...");
>              }
>              llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gForwardThrust,0,0>);
>          }
>          if(level & CONTROL_BACK)
>          {
>              llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <gReverseThrust,0,0>); // back us up
>              return;
>          }
>          if(level & (CONTROL_UP))
>          {
>              HovHeightBase = HovHeightBase + 0.02;
>              llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, HovHeightBase);
>          }
>          if(level & (CONTROL_DOWN))
>          {
>              HovHeightBase = HovHeightBase - 0.02;
>              llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, HovHeightBase);
>          }
>          if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0,-5.0>);
>          if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT)) llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 5.0>);
>          if(edge & ~level & (CONTROL_FWD|CONTROL_BACK)) Treading();
>      }
>
> I might add this is actually from my swim ball script which also works just fine in ubODE but fails in Bullet on the dive and surface actions.
>
> In bullet nothing at all happens.
>
> Is this a bug in opensim?  I know it is expected a script that works in one physics engine is suppose to work in the other physics engines as well.
>
> Not being an expert at script writing, it is possible I stumbled into doing something wrong that ubODE can deal with and Bullet can?t.
>
> Tom
> **********************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20170501/d648d522/attachment.html>


More information about the Opensim-users mailing list