public ConvexHullSet GetConvexHulls() { ConvexHullSet hullSet = m_mesher.GetConvexHulls(this); if (hullSet != null) m_volume = hullSet.Volume * Prim.Scale.X * Prim.Scale.Y * Prim.Scale.Z; return hullSet; }
private void UpdateVolume() { PhysicsType type = GetPhysicsType(); Vector3 scale = Scale; switch (type) { case PhysicsType.Box: m_volume = scale.X * scale.Y * scale.Z; break; case PhysicsType.Sphere: m_volume = 4.1887902f * scale.X * scale.Y * scale.Z; break; case PhysicsType.Cylinder: m_volume = Utils.PI * scale.X * scale.Y * scale.Z; break; case PhysicsType.ConvexHull: ConvexHullSet hullSet = m_mesher.GetConvexHulls(this); if (hullSet != null) m_volume = hullSet.Volume; else m_volume = scale.X * scale.Y * Scale.Z; break; default: m_log.Warn("LLPrimitive has an unhandled physics proxy type: " + type); m_volume = scale.X * scale.Y * scale.Z; break; } }
public void ConvexHullSetSerializationTest() { const int HULLS = 13; const int MAX_VERTICES = 499; const int MAX_INDICES = 1009; ConvexHullSet hullSet = new ConvexHullSet(); hullSet.Volume = 42f; hullSet.Parts = new ConvexHullSet.HullPart[HULLS]; for (int i = 0; i < HULLS; i++) { ConvexHullSet.HullPart part = new ConvexHullSet.HullPart(); part.Offset = RandomVector(); part.Vertices = new Vector3[m_rng.Next(MAX_VERTICES)]; for (int j = 0; j < part.Vertices.Length; j++) { part.Vertices[j] = RandomVector(); } part.Indices = new int[m_rng.Next(MAX_INDICES)]; for (int j = 0; j < part.Indices.Length; j++) { part.Indices[j] = m_rng.Next(part.Vertices.Length); } hullSet.Parts[i] = part; } byte[] data = hullSet.Serialize(); ConvexHullSet hullSet2 = ConvexHullSet.Deserialize(data); Assert.AreEqual(hullSet.Volume, hullSet2.Volume); Assert.AreEqual(hullSet.Parts.Length, hullSet2.Parts.Length); for (int i = 0; i < hullSet.Parts.Length; i++) { ConvexHullSet.HullPart part = hullSet.Parts[i]; ConvexHullSet.HullPart part2 = hullSet2.Parts[i]; Assert.AreEqual(part.Offset, part2.Offset); Assert.AreEqual(part.Vertices.Length, part2.Vertices.Length); Assert.AreEqual(part.Indices.Length, part2.Indices.Length); for (int j = 0; j < part.Vertices.Length; j++) { Vector3 v = part.Vertices[j]; Vector3 v2 = part2.Vertices[j]; Assert.AreEqual(v, v2); } for (int j = 0; j < part.Indices.Length; j++) { int idx = part.Indices[j]; int idx2 = part2.Indices[j]; Assert.AreEqual(idx, idx2); } } }