BulletSim: update DLLs and SOs with better debugging output.

Add definition of hand crafted avatar mesh. Not used yet.
Comments and cleanup.
user_profiles
Robert Adams 2013-01-06 14:01:15 -08:00
parent 2eba80a8cd
commit 9393403253
8 changed files with 151 additions and 12 deletions

View File

@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
get { return Type != Vehicle.TYPE_NONE && Prim.IsPhysical; }
}
#region Vehicle parameter setting
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
{
VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue);
@ -546,6 +547,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
m_verticalAttractionMotor.FrictionTimescale = new Vector3(BSMotor.Infinite, BSMotor.Infinite, 0.1f);
m_verticalAttractionMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG DEBUG (enables detail logging)
}
#endregion // Vehicle parameter setting
// Some of the properties of this prim may have changed.
// Do any updating needed for a vehicle
@ -925,7 +927,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// TODO: Consider taking the rotated size of the object or possibly casting a ray.
if (VehiclePosition.Z < GetTerrainHeight(VehiclePosition))
{
// TODO: correct position by applying force rather than forcing position.
// Force position because applying force won't get the vehicle through the terrain
Vector3 newPosition = VehiclePosition;
newPosition.Z = GetTerrainHeight(VehiclePosition) + 1f;
VehiclePosition = newPosition;

View File

@ -27,24 +27,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OMV = OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin
{
public abstract class BSShape
{
public IntPtr ptr { get; set; }
public BSPhysicsShapeType type { get; set; }
public System.UInt64 key { get; set; }
public int referenceCount { get; set; }
public DateTime lastReferenced { get; set; }
public BSShape()
{
ptr = IntPtr.Zero;
type = BSPhysicsShapeType.SHAPE_UNKNOWN;
key = 0;
referenceCount = 0;
lastReferenced = DateTime.Now;
}
@ -63,7 +58,7 @@ public abstract class BSShape
}
// Compound shapes are handled special as they are rebuilt from scratch.
// This isn't too great a hardship since most of the child shapes will already been created.
// This isn't too great a hardship since most of the child shapes will have already been created.
if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND)
{
// Getting a reference to a compound shape gets you the compound shape with the root prim shape added
@ -71,6 +66,14 @@ public abstract class BSShape
physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret);
}
// Avatars have their own unique shape
if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_AVATAR)
{
// Getting a reference to a compound shape gets you the compound shape with the root prim shape added
ret = BSShapeAvatar.GetReference(prim);
physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,avatarShape,shape={1}", prim.LocalID, ret);
}
if (ret == null)
ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim);
@ -228,5 +231,131 @@ public class BSShapeAvatar : BSShape
return new BSShapeNull();
}
public override void Dereference(BSScene physicsScene) { }
// From the front:
// A---A
// / \
// B-------B
// / \ +Z
// C-----------C |
// \ / -Y --+-- +Y
// \ / |
// \ / -Z
// D-----D
// \ /
// E-E
// From the top A and E are just lines.
// B, C and D are hexagons:
//
// C1--C2 +X
// / \ |
// C0 C3 -Y --+-- +Y
// \ / |
// C5--C4 -X
// Zero goes directly through the middle so the offsets are from that middle axis
// and up and down from a middle horizon (A and E are the same distance from the zero).
// The height, width and depth is one. All scaling is done by the simulator.
// Z component -- how far the level is from the middle zero
private const float Aup = 0.5f;
private const float Bup = 0.4f;
private const float Cup = 0.3f;
private const float Dup = -0.4f;
private const float Eup = -0.5f;
// Y component -- distance from center to x0 and x3
private const float Awid = 0.25f;
private const float Bwid = 0.3f;
private const float Cwid = 0.5f;
private const float Dwid = 0.3f;
private const float Ewid = 0.2f;
// Y component -- distance from center to x1, x2, x4 and x5
private const float Afwid = 0.0f;
private const float Bfwid = 0.2f;
private const float Cfwid = 0.4f;
private const float Dfwid = 0.2f;
private const float Efwid = 0.0f;
// X component -- distance from zero to the front or back of a level
private const float Adep = 0f;
private const float Bdep = 0.3f;
private const float Cdep = 0.5f;
private const float Ddep = 0.2f;
private const float Edep = 0f;
private OMV.Vector3[] avatarVertices = {
new OMV.Vector3( 0.0f, -Awid, Aup), // A0
new OMV.Vector3( 0.0f, +Awid, Aup), // A3
new OMV.Vector3( 0.0f, -Bwid, Bup), // B0
new OMV.Vector3(+Bdep, -Bfwid, Bup), // B1
new OMV.Vector3(+Bdep, +Bfwid, Bup), // B2
new OMV.Vector3( 0.0f, +Bwid, Bup), // B3
new OMV.Vector3(-Bdep, +Bfwid, Bup), // B4
new OMV.Vector3(-Bdep, -Bfwid, Bup), // B5
new OMV.Vector3( 0.0f, -Cwid, Cup), // C0
new OMV.Vector3(+Cdep, -Cfwid, Cup), // C1
new OMV.Vector3(+Cdep, +Cfwid, Cup), // C2
new OMV.Vector3( 0.0f, +Cwid, Cup), // C3
new OMV.Vector3(-Cdep, +Cfwid, Cup), // C4
new OMV.Vector3(-Cdep, -Cfwid, Cup), // C5
new OMV.Vector3( 0.0f, -Dwid, Dup), // D0
new OMV.Vector3(+Ddep, -Dfwid, Dup), // D1
new OMV.Vector3(+Ddep, +Dfwid, Dup), // D2
new OMV.Vector3( 0.0f, +Dwid, Dup), // D3
new OMV.Vector3(-Ddep, +Dfwid, Dup), // D4
new OMV.Vector3(-Ddep, -Dfwid, Dup), // D5
new OMV.Vector3( 0.0f, -Ewid, Eup), // E0
new OMV.Vector3( 0.0f, +Ewid, Eup), // E3
};
// Offsets of the vertices in the vertices array
private enum Ind : int
{
A0, A3,
B0, B1, B2, B3, B4, B5,
C0, C1, C2, C3, C4, C5,
D0, D1, D2, D3, D4, D5,
E0, E3
}
// Comments specify trianges and quads in clockwise direction
private Ind[] avatarIndices = {
Ind.A0, Ind.B0, Ind.B1, // A0,B0,B1
Ind.A0, Ind.B1, Ind.B2, Ind.B2, Ind.A3, Ind.A0, // A0,B1,B2,A3
Ind.A3, Ind.B2, Ind.B3, // A3,B2,B3
Ind.A3, Ind.B3, Ind.B4, // A3,B3,B4
Ind.A3, Ind.B4, Ind.B5, Ind.B5, Ind.A0, Ind.A3, // A3,B4,B5,A0
Ind.A0, Ind.B5, Ind.B0, // A0,B5,B0
Ind.B0, Ind.C0, Ind.C1, Ind.C1, Ind.B1, Ind.B0, // B0,C0,C1,B1
Ind.B1, Ind.C1, Ind.C2, Ind.C2, Ind.B2, Ind.B1, // B1,C1,C2,B2
Ind.B2, Ind.C2, Ind.C3, Ind.C3, Ind.B3, Ind.B2, // B2,C2,C3,B3
Ind.B3, Ind.C3, Ind.C4, Ind.C4, Ind.B4, Ind.B3, // B3,C3,C4,B4
Ind.B4, Ind.C4, Ind.C5, Ind.C5, Ind.B5, Ind.B4, // B4,C4,C5,B5
Ind.B5, Ind.C5, Ind.C0, Ind.C0, Ind.B0, Ind.B5, // B5,C5,C0,B0
Ind.C0, Ind.D0, Ind.D1, Ind.D1, Ind.C1, Ind.C0, // C0,D0,D1,C1
Ind.C1, Ind.D1, Ind.D2, Ind.D2, Ind.C2, Ind.C1, // C1,D1,D2,C2
Ind.C2, Ind.D2, Ind.D3, Ind.D3, Ind.C3, Ind.C2, // C2,D2,D3,C3
Ind.C3, Ind.D3, Ind.D4, Ind.D4, Ind.C4, Ind.C3, // C3,D3,D4,C4
Ind.C4, Ind.D4, Ind.D5, Ind.D5, Ind.C5, Ind.C4, // C4,D4,D5,C5
Ind.C5, Ind.D5, Ind.D0, Ind.D0, Ind.C0, Ind.C5, // C5,D5,D0,C0
Ind.E0, Ind.D0, Ind.D1, // E0,D0,D1
Ind.E0, Ind.D1, Ind.D2, Ind.D2, Ind.E3, Ind.E0, // E0,D1,D2,E3
Ind.E3, Ind.D2, Ind.D3, // E3,D2,D3
Ind.E3, Ind.D3, Ind.D4, // E3,D3,D4
Ind.E3, Ind.D4, Ind.D5, Ind.D5, Ind.E0, Ind.E3, // E3,D4,D5,E0
Ind.E0, Ind.D5, Ind.D0, // E0,D5,D0
};
}
}

View File

@ -114,8 +114,10 @@ public class BulletShape
public virtual void Clear() { }
public virtual bool HasPhysicalShape { get { return false; } }
// Make another reference to this physical object.
public virtual BulletShape Clone() { return new BulletShape(); }
// Return 'true' if this and other refer to the same physical object
public virtual bool ReferenceSame(BulletShape xx) { return false; }

View File

@ -1,8 +1,6 @@
CURRENT PRIORITIES
=================================================
Redo BulletSimAPI to allow native C# implementation of Bullet option (DONE)
Meshes rendering as bounding boxes
llMoveToTarget
Avatars walking up stairs
Vehicle movement on terrain smoothness
limitMotorUp calibration (more down?)
Preferred orientatino angular correction fix
@ -135,6 +133,9 @@ Eliminate collisions between objects in a linkset. (LinksetConstraint)
MORE
======================================================
Use the HACD convex hull routine in Bullet rather than the C# version.
Do we need to do convex hulls all the time? Can complex meshes be left meshes?
There is some problem with meshes and collisions
Test avatar walking up stairs. How does compare with SL.
Radius of the capsule affects ability to climb edges.
Debounce avatar contact so legs don't keep folding up when standing.
@ -274,3 +275,8 @@ llSetBuoyancy() (DONE)
(Resolution: Bullet resets object gravity when added to world. Moved set gravity)
Avatar density is WAY off. Compare and calibrate with what's in SL. (DONE)
(Resolution: set default density to 3.5 (from 60) which is closer to SL)
Redo BulletSimAPI to allow native C# implementation of Bullet option (DONE)
(Resolution: added BSAPITemplate and then interfaces for C++ Bullet and C# BulletXNA
Meshes rendering as bounding boxes (DONE)
(Resolution: Added test for mesh/sculpties in native shapes so it didn't think it was a box)
llMoveToTarget (Resolution: added simple motor to update the position.)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.