diff options
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 3 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 55 |
2 files changed, 4 insertions, 54 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 5cff668..9a9e527 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -90,7 +90,6 @@ public static class BSParam | |||
90 | public static bool ShouldUseBulletHACD { get; set; } | 90 | public static bool ShouldUseBulletHACD { get; set; } |
91 | public static bool ShouldUseSingleConvexHullForPrims { get; set; } | 91 | public static bool ShouldUseSingleConvexHullForPrims { get; set; } |
92 | public static bool ShouldUseGImpactShapeForPrims { get; set; } | 92 | public static bool ShouldUseGImpactShapeForPrims { get; set; } |
93 | public static bool ShouldUseAssetHulls { get; set; } | ||
94 | 93 | ||
95 | public static float TerrainImplementation { get; set; } | 94 | public static float TerrainImplementation { get; set; } |
96 | public static int TerrainMeshMagnification { get; private set; } | 95 | public static int TerrainMeshMagnification { get; private set; } |
@@ -373,8 +372,6 @@ public static class BSParam | |||
373 | true ), | 372 | true ), |
374 | new ParameterDefn<bool>("ShouldUseGImpactShapeForPrims", "If true, use a GImpact shape for prims with cuts and twists", | 373 | new ParameterDefn<bool>("ShouldUseGImpactShapeForPrims", "If true, use a GImpact shape for prims with cuts and twists", |
375 | false ), | 374 | false ), |
376 | new ParameterDefn<bool>("UseAssetHulls", "If true, use hull if specified in the mesh asset info", | ||
377 | false ), | ||
378 | 375 | ||
379 | new ParameterDefn<int>("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions", | 376 | new ParameterDefn<int>("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions", |
380 | 5 ), | 377 | 5 ), |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index b7f7e6c..0152233 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -31,7 +31,6 @@ using System.Text; | |||
31 | 31 | ||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Physics.Manager; | 33 | using OpenSim.Region.Physics.Manager; |
34 | using OpenSim.Region.Physics.Meshing; | ||
35 | using OpenSim.Region.Physics.ConvexDecompositionDotNet; | 34 | using OpenSim.Region.Physics.ConvexDecompositionDotNet; |
36 | 35 | ||
37 | using OMV = OpenMetaverse; | 36 | using OMV = OpenMetaverse; |
@@ -574,56 +573,9 @@ public class BSShapeHull : BSShape | |||
574 | PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 573 | PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
575 | { | 574 | { |
576 | BulletShape newShape = new BulletShape(); | 575 | BulletShape newShape = new BulletShape(); |
577 | newShape.shapeKey = newHullKey; | 576 | IntPtr hullPtr = IntPtr.Zero; |
578 | 577 | ||
579 | // Pass true for physicalness as this prevents the creation of bounding box which is not needed | 578 | if (BSParam.ShouldUseBulletHACD) |
580 | IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */); | ||
581 | |||
582 | // If there is hull data in the mesh asset, build the hull from that | ||
583 | if (meshData != null && BSParam.ShouldUseAssetHulls) | ||
584 | { | ||
585 | Meshmerizer realMesher = physicsScene.mesher as Meshmerizer; | ||
586 | if (realMesher != null) | ||
587 | { | ||
588 | List<List<OMV.Vector3>> allHulls = realMesher.GetConvexHulls(size); | ||
589 | if (allHulls != null) | ||
590 | { | ||
591 | int hullCount = allHulls.Count; | ||
592 | int totalVertices = 1; // include one for the count of the hulls | ||
593 | // Using the structure described for HACD hulls, create the memory sturcture | ||
594 | // to pass the hull data to the creater. | ||
595 | foreach (List<OMV.Vector3> hullVerts in allHulls) | ||
596 | { | ||
597 | totalVertices += 4; // add four for the vertex count and centroid | ||
598 | totalVertices += hullVerts.Count * 3; // one vertex is three dimensions | ||
599 | } | ||
600 | float[] convHulls = new float[totalVertices]; | ||
601 | |||
602 | convHulls[0] = (float)hullCount; | ||
603 | int jj = 1; | ||
604 | foreach (List<OMV.Vector3> hullVerts in allHulls) | ||
605 | { | ||
606 | convHulls[jj + 0] = hullVerts.Count; | ||
607 | convHulls[jj + 1] = 0f; // centroid x,y,z | ||
608 | convHulls[jj + 2] = 0f; | ||
609 | convHulls[jj + 3] = 0f; | ||
610 | jj += 4; | ||
611 | foreach (OMV.Vector3 oneVert in hullVerts) | ||
612 | { | ||
613 | convHulls[jj + 0] = oneVert.X; | ||
614 | convHulls[jj + 1] = oneVert.Y; | ||
615 | convHulls[jj + 2] = oneVert.Z; | ||
616 | jj += 3; | ||
617 | } | ||
618 | } | ||
619 | |||
620 | // create the hull data structure in Bullet | ||
621 | newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); | ||
622 | } | ||
623 | } | ||
624 | } | ||
625 | // If no hull specified in the asset and we should use Bullet's HACD approximation... | ||
626 | if (!newShape.HasPhysicalShape && BSParam.ShouldUseBulletHACD) | ||
627 | { | 579 | { |
628 | // Build the hull shape from an existing mesh shape. | 580 | // Build the hull shape from an existing mesh shape. |
629 | // The mesh should have already been created in Bullet. | 581 | // The mesh should have already been created in Bullet. |
@@ -652,10 +604,11 @@ public class BSShapeHull : BSShape | |||
652 | } | 604 | } |
653 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); | 605 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); |
654 | } | 606 | } |
655 | // If no hull specified, use our HACD hull approximation. | ||
656 | if (!newShape.HasPhysicalShape) | 607 | if (!newShape.HasPhysicalShape) |
657 | { | 608 | { |
658 | // Build a new hull in the physical world using the C# HACD algorigthm. | 609 | // Build a new hull in the physical world using the C# HACD algorigthm. |
610 | // Pass true for physicalness as this prevents the creation of bounding box which is not needed | ||
611 | IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */); | ||
659 | if (meshData != null) | 612 | if (meshData != null) |
660 | { | 613 | { |
661 | if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) | 614 | if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) |