aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs96
1 files changed, 48 insertions, 48 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 8013e68..aeeb4dd 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -46,8 +46,6 @@ public sealed class BSPrim : BSPhysObject
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private static readonly string LogHeader = "[BULLETS PRIM]"; 47 private static readonly string LogHeader = "[BULLETS PRIM]";
48 48
49 private PrimitiveBaseShape _pbs;
50
51 // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. 49 // _size is what the user passed. Scale is what we pass to the physics engine with the mesh.
52 // Often Scale is unity because the meshmerizer will apply _size when creating the mesh. 50 // Often Scale is unity because the meshmerizer will apply _size when creating the mesh.
53 private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user 51 private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user
@@ -103,7 +101,7 @@ public sealed class BSPrim : BSPhysObject
103 _buoyancy = 1f; 101 _buoyancy = 1f;
104 _velocity = OMV.Vector3.Zero; 102 _velocity = OMV.Vector3.Zero;
105 _rotationalVelocity = OMV.Vector3.Zero; 103 _rotationalVelocity = OMV.Vector3.Zero;
106 _pbs = pbs; 104 BaseShape = pbs;
107 _isPhysical = pisPhysical; 105 _isPhysical = pisPhysical;
108 _isVolumeDetect = false; 106 _isVolumeDetect = false;
109 _friction = PhysicsScene.Params.defaultFriction; // TODO: compute based on object material 107 _friction = PhysicsScene.Params.defaultFriction; // TODO: compute based on object material
@@ -160,14 +158,7 @@ public sealed class BSPrim : BSPhysObject
160 get { return _size; } 158 get { return _size; }
161 set { 159 set {
162 _size = value; 160 _size = value;
163 PhysicsScene.TaintedObject("BSPrim.setSize", delegate() 161 ForceBodyShapeRebuild(false);
164 {
165 _mass = CalculateMass(); // changing size changes the mass
166 // Since _size changed, the mesh needs to be rebuilt. If rebuilt, all the correct
167 // scale and margins are set.
168 CreateGeomAndObject(true);
169 // DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, Scale, _mass, IsPhysical);
170 });
171 } 162 }
172 } 163 }
173 // Scale is what we set in the physics engine. It is different than 'size' in that 164 // Scale is what we set in the physics engine. It is different than 'size' in that
@@ -176,14 +167,23 @@ public sealed class BSPrim : BSPhysObject
176 167
177 public override PrimitiveBaseShape Shape { 168 public override PrimitiveBaseShape Shape {
178 set { 169 set {
179 _pbs = value; 170 BaseShape = value;
180 PhysicsScene.TaintedObject("BSPrim.setShape", delegate() 171 ForceBodyShapeRebuild(false);
181 {
182 _mass = CalculateMass(); // changing the shape changes the mass
183 CreateGeomAndObject(true);
184 });
185 } 172 }
186 } 173 }
174 public override bool ForceBodyShapeRebuild(bool inTaintTime)
175 {
176 BSScene.TaintCallback rebuildOperation = delegate()
177 {
178 _mass = CalculateMass(); // changing the shape changes the mass
179 CreateGeomAndObject(true);
180 };
181 if (inTaintTime)
182 rebuildOperation();
183 else
184 PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", rebuildOperation);
185 return true;
186 }
187 public override bool Grabbed { 187 public override bool Grabbed {
188 set { _grabbed = value; 188 set { _grabbed = value;
189 } 189 }
@@ -924,19 +924,19 @@ public sealed class BSPrim : BSPhysObject
924 float tmp; 924 float tmp;
925 925
926 float returnMass = 0; 926 float returnMass = 0;
927 float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f; 927 float hollowAmount = (float)BaseShape.ProfileHollow * 2.0e-5f;
928 float hollowVolume = hollowAmount * hollowAmount; 928 float hollowVolume = hollowAmount * hollowAmount;
929 929
930 switch (_pbs.ProfileShape) 930 switch (BaseShape.ProfileShape)
931 { 931 {
932 case ProfileShape.Square: 932 case ProfileShape.Square:
933 // default box 933 // default box
934 934
935 if (_pbs.PathCurve == (byte)Extrusion.Straight) 935 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
936 { 936 {
937 if (hollowAmount > 0.0) 937 if (hollowAmount > 0.0)
938 { 938 {
939 switch (_pbs.HollowShape) 939 switch (BaseShape.HollowShape)
940 { 940 {
941 case HollowShape.Square: 941 case HollowShape.Square:
942 case HollowShape.Same: 942 case HollowShape.Same:
@@ -960,19 +960,19 @@ public sealed class BSPrim : BSPhysObject
960 } 960 }
961 } 961 }
962 962
963 else if (_pbs.PathCurve == (byte)Extrusion.Curve1) 963 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
964 { 964 {
965 //a tube 965 //a tube
966 966
967 volume *= 0.78539816339e-2f * (float)(200 - _pbs.PathScaleX); 967 volume *= 0.78539816339e-2f * (float)(200 - BaseShape.PathScaleX);
968 tmp= 1.0f -2.0e-2f * (float)(200 - _pbs.PathScaleY); 968 tmp= 1.0f -2.0e-2f * (float)(200 - BaseShape.PathScaleY);
969 volume -= volume*tmp*tmp; 969 volume -= volume*tmp*tmp;
970 970
971 if (hollowAmount > 0.0) 971 if (hollowAmount > 0.0)
972 { 972 {
973 hollowVolume *= hollowAmount; 973 hollowVolume *= hollowAmount;
974 974
975 switch (_pbs.HollowShape) 975 switch (BaseShape.HollowShape)
976 { 976 {
977 case HollowShape.Square: 977 case HollowShape.Square:
978 case HollowShape.Same: 978 case HollowShape.Same:
@@ -997,13 +997,13 @@ public sealed class BSPrim : BSPhysObject
997 997
998 case ProfileShape.Circle: 998 case ProfileShape.Circle:
999 999
1000 if (_pbs.PathCurve == (byte)Extrusion.Straight) 1000 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
1001 { 1001 {
1002 volume *= 0.78539816339f; // elipse base 1002 volume *= 0.78539816339f; // elipse base
1003 1003
1004 if (hollowAmount > 0.0) 1004 if (hollowAmount > 0.0)
1005 { 1005 {
1006 switch (_pbs.HollowShape) 1006 switch (BaseShape.HollowShape)
1007 { 1007 {
1008 case HollowShape.Same: 1008 case HollowShape.Same:
1009 case HollowShape.Circle: 1009 case HollowShape.Circle:
@@ -1025,10 +1025,10 @@ public sealed class BSPrim : BSPhysObject
1025 } 1025 }
1026 } 1026 }
1027 1027
1028 else if (_pbs.PathCurve == (byte)Extrusion.Curve1) 1028 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1029 { 1029 {
1030 volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - _pbs.PathScaleX); 1030 volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - BaseShape.PathScaleX);
1031 tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY); 1031 tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY);
1032 volume *= (1.0f - tmp * tmp); 1032 volume *= (1.0f - tmp * tmp);
1033 1033
1034 if (hollowAmount > 0.0) 1034 if (hollowAmount > 0.0)
@@ -1037,7 +1037,7 @@ public sealed class BSPrim : BSPhysObject
1037 // calculate the hollow volume by it's shape compared to the prim shape 1037 // calculate the hollow volume by it's shape compared to the prim shape
1038 hollowVolume *= hollowAmount; 1038 hollowVolume *= hollowAmount;
1039 1039
1040 switch (_pbs.HollowShape) 1040 switch (BaseShape.HollowShape)
1041 { 1041 {
1042 case HollowShape.Same: 1042 case HollowShape.Same:
1043 case HollowShape.Circle: 1043 case HollowShape.Circle:
@@ -1061,7 +1061,7 @@ public sealed class BSPrim : BSPhysObject
1061 break; 1061 break;
1062 1062
1063 case ProfileShape.HalfCircle: 1063 case ProfileShape.HalfCircle:
1064 if (_pbs.PathCurve == (byte)Extrusion.Curve1) 1064 if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1065 { 1065 {
1066 volume *= 0.52359877559829887307710723054658f; 1066 volume *= 0.52359877559829887307710723054658f;
1067 } 1067 }
@@ -1069,7 +1069,7 @@ public sealed class BSPrim : BSPhysObject
1069 1069
1070 case ProfileShape.EquilateralTriangle: 1070 case ProfileShape.EquilateralTriangle:
1071 1071
1072 if (_pbs.PathCurve == (byte)Extrusion.Straight) 1072 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
1073 { 1073 {
1074 volume *= 0.32475953f; 1074 volume *= 0.32475953f;
1075 1075
@@ -1077,7 +1077,7 @@ public sealed class BSPrim : BSPhysObject
1077 { 1077 {
1078 1078
1079 // calculate the hollow volume by it's shape compared to the prim shape 1079 // calculate the hollow volume by it's shape compared to the prim shape
1080 switch (_pbs.HollowShape) 1080 switch (BaseShape.HollowShape)
1081 { 1081 {
1082 case HollowShape.Same: 1082 case HollowShape.Same:
1083 case HollowShape.Triangle: 1083 case HollowShape.Triangle:
@@ -1102,11 +1102,11 @@ public sealed class BSPrim : BSPhysObject
1102 volume *= (1.0f - hollowVolume); 1102 volume *= (1.0f - hollowVolume);
1103 } 1103 }
1104 } 1104 }
1105 else if (_pbs.PathCurve == (byte)Extrusion.Curve1) 1105 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1106 { 1106 {
1107 volume *= 0.32475953f; 1107 volume *= 0.32475953f;
1108 volume *= 0.01f * (float)(200 - _pbs.PathScaleX); 1108 volume *= 0.01f * (float)(200 - BaseShape.PathScaleX);
1109 tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY); 1109 tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY);
1110 volume *= (1.0f - tmp * tmp); 1110 volume *= (1.0f - tmp * tmp);
1111 1111
1112 if (hollowAmount > 0.0) 1112 if (hollowAmount > 0.0)
@@ -1114,7 +1114,7 @@ public sealed class BSPrim : BSPhysObject
1114 1114
1115 hollowVolume *= hollowAmount; 1115 hollowVolume *= hollowAmount;
1116 1116
1117 switch (_pbs.HollowShape) 1117 switch (BaseShape.HollowShape)
1118 { 1118 {
1119 case HollowShape.Same: 1119 case HollowShape.Same:
1120 case HollowShape.Triangle: 1120 case HollowShape.Triangle:
@@ -1154,26 +1154,26 @@ public sealed class BSPrim : BSPhysObject
1154 float profileBegin; 1154 float profileBegin;
1155 float profileEnd; 1155 float profileEnd;
1156 1156
1157 if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) 1157 if (BaseShape.PathCurve == (byte)Extrusion.Straight || BaseShape.PathCurve == (byte)Extrusion.Flexible)
1158 { 1158 {
1159 taperX1 = _pbs.PathScaleX * 0.01f; 1159 taperX1 = BaseShape.PathScaleX * 0.01f;
1160 if (taperX1 > 1.0f) 1160 if (taperX1 > 1.0f)
1161 taperX1 = 2.0f - taperX1; 1161 taperX1 = 2.0f - taperX1;
1162 taperX = 1.0f - taperX1; 1162 taperX = 1.0f - taperX1;
1163 1163
1164 taperY1 = _pbs.PathScaleY * 0.01f; 1164 taperY1 = BaseShape.PathScaleY * 0.01f;
1165 if (taperY1 > 1.0f) 1165 if (taperY1 > 1.0f)
1166 taperY1 = 2.0f - taperY1; 1166 taperY1 = 2.0f - taperY1;
1167 taperY = 1.0f - taperY1; 1167 taperY = 1.0f - taperY1;
1168 } 1168 }
1169 else 1169 else
1170 { 1170 {
1171 taperX = _pbs.PathTaperX * 0.01f; 1171 taperX = BaseShape.PathTaperX * 0.01f;
1172 if (taperX < 0.0f) 1172 if (taperX < 0.0f)
1173 taperX = -taperX; 1173 taperX = -taperX;
1174 taperX1 = 1.0f - taperX; 1174 taperX1 = 1.0f - taperX;
1175 1175
1176 taperY = _pbs.PathTaperY * 0.01f; 1176 taperY = BaseShape.PathTaperY * 0.01f;
1177 if (taperY < 0.0f) 1177 if (taperY < 0.0f)
1178 taperY = -taperY; 1178 taperY = -taperY;
1179 taperY1 = 1.0f - taperY; 1179 taperY1 = 1.0f - taperY;
@@ -1183,13 +1183,13 @@ public sealed class BSPrim : BSPhysObject
1183 1183
1184 volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); 1184 volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY);
1185 1185
1186 pathBegin = (float)_pbs.PathBegin * 2.0e-5f; 1186 pathBegin = (float)BaseShape.PathBegin * 2.0e-5f;
1187 pathEnd = 1.0f - (float)_pbs.PathEnd * 2.0e-5f; 1187 pathEnd = 1.0f - (float)BaseShape.PathEnd * 2.0e-5f;
1188 volume *= (pathEnd - pathBegin); 1188 volume *= (pathEnd - pathBegin);
1189 1189
1190 // this is crude aproximation 1190 // this is crude aproximation
1191 profileBegin = (float)_pbs.ProfileBegin * 2.0e-5f; 1191 profileBegin = (float)BaseShape.ProfileBegin * 2.0e-5f;
1192 profileEnd = 1.0f - (float)_pbs.ProfileEnd * 2.0e-5f; 1192 profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f;
1193 volume *= (profileEnd - profileBegin); 1193 volume *= (profileEnd - profileBegin);
1194 1194
1195 returnMass = _density * volume; 1195 returnMass = _density * volume;
@@ -1251,7 +1251,7 @@ public sealed class BSPrim : BSPhysObject
1251 // Create the correct physical representation for this type of object. 1251 // Create the correct physical representation for this type of object.
1252 // Updates BSBody and BSShape with the new information. 1252 // Updates BSBody and BSShape with the new information.
1253 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. 1253 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
1254 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, _pbs, 1254 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape,
1255 null, delegate(BulletBody dBody) 1255 null, delegate(BulletBody dBody)
1256 { 1256 {
1257 // Called if the current prim body is about to be destroyed. 1257 // Called if the current prim body is about to be destroyed.