ubOde suport convex shapes on all normal prims and sculpts. Since code is experimental this is controled by options ConvexPrims and ConvexSculpts, on section Mesh, that can be set to false in case of problems
parent
4293b2cb3c
commit
66a5b4d120
|
@ -43,8 +43,6 @@ using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
|
|
||||||
using Mono.Addins;
|
using Mono.Addins;
|
||||||
|
|
||||||
|
@ -72,6 +70,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
private const string baseDir = null; //"rawFiles";
|
private const string baseDir = null; //"rawFiles";
|
||||||
|
|
||||||
private bool useMeshiesPhysicsMesh = false;
|
private bool useMeshiesPhysicsMesh = false;
|
||||||
|
private bool doConvexPrims = true;
|
||||||
|
private bool doConvexSculpts = true;
|
||||||
|
|
||||||
private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
|
private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
|
||||||
|
|
||||||
|
@ -103,18 +103,14 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
if (mesh_config != null)
|
if (mesh_config != null)
|
||||||
{
|
{
|
||||||
useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
|
useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
|
||||||
if (useMeshiesPhysicsMesh)
|
|
||||||
{
|
doConvexPrims = mesh_config.GetBoolean("ConvexPrims",doConvexPrims);
|
||||||
doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
|
doConvexSculpts = mesh_config.GetBoolean("ConvexSculpts",doConvexPrims);
|
||||||
cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
|
|
||||||
fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache);
|
doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
|
||||||
doCacheExpire = mesh_config.GetBoolean("MeshFileCacheDoExpire", doCacheExpire);
|
cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
|
||||||
}
|
fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache);
|
||||||
else
|
doCacheExpire = mesh_config.GetBoolean("MeshFileCacheDoExpire", doCacheExpire);
|
||||||
{
|
|
||||||
doMeshFileCache = false;
|
|
||||||
doCacheExpire = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Enabled = true;
|
m_Enabled = true;
|
||||||
}
|
}
|
||||||
|
@ -330,6 +326,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
|
|
||||||
List<Coord> coords;
|
List<Coord> coords;
|
||||||
List<Face> faces;
|
List<Face> faces;
|
||||||
|
bool needsConvexProcessing = convex;
|
||||||
|
|
||||||
if (primShape.SculptEntry)
|
if (primShape.SculptEntry)
|
||||||
{
|
{
|
||||||
|
@ -340,23 +337,49 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
|
|
||||||
if (!GenerateCoordsAndFacesFromPrimMeshData(primName, primShape, out coords, out faces, convex))
|
if (!GenerateCoordsAndFacesFromPrimMeshData(primName, primShape, out coords, out faces, convex))
|
||||||
return null;
|
return null;
|
||||||
|
needsConvexProcessing = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!GenerateCoordsAndFacesFromPrimSculptData(primName, primShape, lod, out coords, out faces))
|
if (!GenerateCoordsAndFacesFromPrimSculptData(primName, primShape, lod, out coords, out faces))
|
||||||
return null;
|
return null;
|
||||||
|
needsConvexProcessing &= doConvexSculpts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!GenerateCoordsAndFacesFromPrimShapeData(primName, primShape, lod, convex, out coords, out faces))
|
if (!GenerateCoordsAndFacesFromPrimShapeData(primName, primShape, lod, convex, out coords, out faces))
|
||||||
return null;
|
return null;
|
||||||
|
needsConvexProcessing &= doConvexPrims;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int numCoords = coords.Count;
|
int numCoords = coords.Count;
|
||||||
int numFaces = faces.Count;
|
int numFaces = faces.Count;
|
||||||
|
|
||||||
|
if(numCoords < 3 || (!needsConvexProcessing && numFaces < 1))
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[MESH]: invalid degenerated mesh for prim {0} ignored", primName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(needsConvexProcessing)
|
||||||
|
{
|
||||||
|
List<Coord> convexcoords;
|
||||||
|
List<Face> convexfaces;
|
||||||
|
if(CreateHull(coords, out convexcoords, out convexfaces) && convexcoords != null && convexfaces != null)
|
||||||
|
{
|
||||||
|
coords.Clear();
|
||||||
|
coords = convexcoords;
|
||||||
|
numCoords = coords.Count;
|
||||||
|
|
||||||
|
faces.Clear();
|
||||||
|
faces = convexfaces;
|
||||||
|
numFaces = faces.Count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_log.ErrorFormat("[ubMESH]: failed to create convex for {0} using normal mesh", primName);
|
||||||
|
}
|
||||||
|
|
||||||
Mesh mesh = new Mesh(true);
|
Mesh mesh = new Mesh(true);
|
||||||
// Add the corresponding triangles to the mesh
|
// Add the corresponding triangles to the mesh
|
||||||
for (int i = 0; i < numFaces; i++)
|
for (int i = 0; i < numFaces; i++)
|
||||||
|
@ -371,10 +394,10 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
faces.Clear();
|
faces.Clear();
|
||||||
|
|
||||||
if(mesh.numberVertices() < 3 || mesh.numberTriangles() < 1)
|
if(mesh.numberVertices() < 3 || mesh.numberTriangles() < 1)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[MESH]: invalid degenerated mesh for prim " + primName + " ignored");
|
m_log.ErrorFormat("[MESH]: invalid degenerated mesh for prim {0} ignored", primName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
primShape.SculptData = Utils.EmptyBytes;
|
primShape.SculptData = Utils.EmptyBytes;
|
||||||
|
|
||||||
|
@ -1583,5 +1606,79 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CreateHull(List<Coord> inputVertices, out List<Coord> convexcoords, out List<Face> newfaces)
|
||||||
|
{
|
||||||
|
convexcoords = null;
|
||||||
|
newfaces = null;
|
||||||
|
HullDesc desc = new HullDesc();
|
||||||
|
HullResult result = new HullResult();
|
||||||
|
|
||||||
|
int nInputVerts = inputVertices.Count;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
List<float3> vs = new List<float3>(nInputVerts);
|
||||||
|
float3 f3;
|
||||||
|
|
||||||
|
//useless copy
|
||||||
|
for(i = 0 ; i < nInputVerts; i++)
|
||||||
|
{
|
||||||
|
f3 = new float3(inputVertices[i].X, inputVertices[i].Y, inputVertices[i].Z);
|
||||||
|
vs.Add(f3);
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.Vertices = vs;
|
||||||
|
desc.Flags = HullFlag.QF_TRIANGLES;
|
||||||
|
desc.MaxVertices = 256;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HullError ret = HullUtils.CreateConvexHull(desc, ref result);
|
||||||
|
if (ret != HullError.QE_OK)
|
||||||
|
return false;
|
||||||
|
int nverts = result.OutputVertices.Count;
|
||||||
|
int nindx = result.Indices.Count;
|
||||||
|
if(nverts < 3 || nindx< 3)
|
||||||
|
return false;
|
||||||
|
if(nindx % 3 != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
convexcoords = new List<Coord>(nverts);
|
||||||
|
Coord c;
|
||||||
|
vs = result.OutputVertices;
|
||||||
|
|
||||||
|
for(i = 0 ; i < nverts; i++)
|
||||||
|
{
|
||||||
|
c = new Coord(vs[i].x, vs[i].y, vs[i].z);
|
||||||
|
convexcoords.Add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
newfaces = new List<Face>(nindx / 3);
|
||||||
|
List<int> indxs = result.Indices;
|
||||||
|
int k, l, m;
|
||||||
|
Face f;
|
||||||
|
for(i = 0 ; i < nindx;)
|
||||||
|
{
|
||||||
|
k = indxs[i++];
|
||||||
|
l = indxs[i++];
|
||||||
|
m = indxs[i++];
|
||||||
|
if(k > nInputVerts)
|
||||||
|
continue;
|
||||||
|
if(l > nInputVerts)
|
||||||
|
continue;
|
||||||
|
if(m > nInputVerts)
|
||||||
|
continue;
|
||||||
|
f = new Face(k,l,m);
|
||||||
|
newfaces.Add(f);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -935,18 +935,35 @@
|
||||||
|
|
||||||
|
|
||||||
[Mesh]
|
[Mesh]
|
||||||
; enable / disable Collada mesh support
|
; enable / disable mesh asset uploads
|
||||||
|
; mesh asset must conform to standard mesh format, with OpenSim extensions
|
||||||
; default is true
|
; default is true
|
||||||
AllowMeshUpload = true
|
AllowMeshUpload = true
|
||||||
|
|
||||||
; if you use Meshmerizer and want collisions for meshies, setting this to true
|
|
||||||
; will cause OpenSim to attempt to decode meshies assets, extract the physics
|
|
||||||
; mesh, and use it for collisions.
|
|
||||||
UseMeshiesPhysicsMesh = true
|
|
||||||
|
|
||||||
; Minimum user level required to upload meshes
|
; Minimum user level required to upload meshes
|
||||||
;LevelUpload = 0
|
;LevelUpload = 0
|
||||||
|
|
||||||
|
; suport meshs on physics
|
||||||
|
;UseMeshiesPhysicsMesh = true
|
||||||
|
|
||||||
|
;suport convex shape type on normal prims
|
||||||
|
; (ubOde only)
|
||||||
|
;ConvexPrims = true
|
||||||
|
|
||||||
|
;suport convex shape type on sculpts
|
||||||
|
; (ubOde only)
|
||||||
|
;ConvexSculpts = true
|
||||||
|
|
||||||
|
; mesh cache settings:
|
||||||
|
; (ubOde only)
|
||||||
|
; do cache (keep true)
|
||||||
|
;MeshFileCache = true
|
||||||
|
; cache folder name relative to bin/ or absolute path
|
||||||
|
;MeshFileCachePath = MeshCache
|
||||||
|
;MeshFileCacheDoExpire = true;
|
||||||
|
;MeshFileCacheExpireHours = 48
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Textures]
|
[Textures]
|
||||||
; If true, textures generated dynamically (i.e. through osSetDynamicTextureData() and similar OSSL functions) are reused where possible
|
; If true, textures generated dynamically (i.e. through osSetDynamicTextureData() and similar OSSL functions) are reused where possible
|
||||||
|
@ -968,7 +985,7 @@
|
||||||
|
|
||||||
[ODEPhysicsSettings]
|
[ODEPhysicsSettings]
|
||||||
; ##
|
; ##
|
||||||
; ## Physics stats settings
|
; ## Physics stats settings ( most ignored by ubOde )
|
||||||
;
|
;
|
||||||
|
|
||||||
; If collect_stats is enabled, then extra stat information is collected which is accessible via the MonitorModule
|
; If collect_stats is enabled, then extra stat information is collected which is accessible via the MonitorModule
|
||||||
|
|
Loading…
Reference in New Issue