From 4056aace244ae3360cbd0260a5f02ed6cc0d5ddf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jul 2022 23:10:22 +0100 Subject: [PATCH] a few more changes to ubode --- .../ubODE-OpenSim/OPCODE/OPC_TriBoxOverlap.h | 13 ++--- trunk/unmanaged/ubODE-OpenSim/configure.ac | 2 +- .../unmanaged/ubODE-OpenSim/ode/src/config.h | 7 +++ .../unmanaged/ubODE-OpenSim/ode/src/plane.cpp | 51 ++++++++++++++++--- trunk/unmanaged/ubODE-OpenSim/ode/src/ray.cpp | 15 +++--- 5 files changed, 69 insertions(+), 19 deletions(-) diff --git a/trunk/unmanaged/ubODE-OpenSim/OPCODE/OPC_TriBoxOverlap.h b/trunk/unmanaged/ubODE-OpenSim/OPCODE/OPC_TriBoxOverlap.h index 4f2026ea..de326e66 100644 --- a/trunk/unmanaged/ubODE-OpenSim/OPCODE/OPC_TriBoxOverlap.h +++ b/trunk/unmanaged/ubODE-OpenSim/OPCODE/OPC_TriBoxOverlap.h @@ -274,24 +274,25 @@ inline_ BOOL AABBCollider::TriBoxOverlap() // First, test overlap in the {x,y,z}-directions // find min, max of the triangle in x-direction, and test for overlap in X - if(FCMin3(v0.x, v1.x, v2.x)>extents.x) return FALSE; - if(FCMax3(v0.x, v1.x, v2.x)<-extents.x) return FALSE; + if (!inExtent(v0.x, v1.x, v2.x, extents.x)) + return FALSE; // same for Y v0.y = mLeafVerts[0].y - center.y; v1.y = mLeafVerts[1].y - center.y; v2.y = mLeafVerts[2].y - center.y; - if(FCMin3(v0.y, v1.y, v2.y)>extents.y) return FALSE; - if(FCMax3(v0.y, v1.y, v2.y)<-extents.y) return FALSE; + if (!inExtent(v0.y, v1.y, v2.y, extents.y)) + return FALSE; // same for Z v0.z = mLeafVerts[0].z - center.z; v1.z = mLeafVerts[1].z - center.z; v2.z = mLeafVerts[2].z - center.z; - if(FCMin3(v0.z, v1.z, v2.z)>extents.z) return FALSE; - if(FCMax3(v0.z, v1.z, v2.z)<-extents.z) return FALSE; + if (!inExtent(v0.z, v1.z, v2.z, extents.z)) + return FALSE; + // 2) Test if the box intersects the plane of the triangle // compute plane equation of triangle: normal*x+d=0 // ### could be precomputed since we use the same leaf triangle several times diff --git a/trunk/unmanaged/ubODE-OpenSim/configure.ac b/trunk/unmanaged/ubODE-OpenSim/configure.ac index aa5a2fe9..2e94ace9 100644 --- a/trunk/unmanaged/ubODE-OpenSim/configure.ac +++ b/trunk/unmanaged/ubODE-OpenSim/configure.ac @@ -1,5 +1,5 @@ dnl AC_INIT does not take a macro as a version nr: set it separately! - Bram -AC_INIT([UBODE],[0.13.4],[ubode@opensimulator.org]) +AC_INIT([UBODE],[0.13.4],[opensim-dev@opensimulator.org]) ODE_VERSION=OS0.13.4 AC_SUBST(ODE_VERSION) diff --git a/trunk/unmanaged/ubODE-OpenSim/ode/src/config.h b/trunk/unmanaged/ubODE-OpenSim/ode/src/config.h index 24cb54d1..7f35a72f 100644 --- a/trunk/unmanaged/ubODE-OpenSim/ode/src/config.h +++ b/trunk/unmanaged/ubODE-OpenSim/ode/src/config.h @@ -34,9 +34,16 @@ #define dTRIMESH_16BIT_INDICES 0 +/* #define dOU_ENABLED 1 #define dATOMICS_ENABLED 1 #define dTLS_ENABLED 1 +*/ + + +#define dOU_ENABLED 0 +#define dATOMICS_ENABLED 0 +#define dTLS_ENABLED 0 #define dTHREADING_INTF_DISABLED 1 /* #define dBUILTIN_THREADING_IMPL_ENABLED 1 */ diff --git a/trunk/unmanaged/ubODE-OpenSim/ode/src/plane.cpp b/trunk/unmanaged/ubODE-OpenSim/ode/src/plane.cpp index f989bd54..0041185d 100644 --- a/trunk/unmanaged/ubODE-OpenSim/ode/src/plane.cpp +++ b/trunk/unmanaged/ubODE-OpenSim/ode/src/plane.cpp @@ -48,7 +48,19 @@ dContactGeom::g1 and dContactGeom::g2. static void make_sure_plane_normal_has_unit_length (dxPlane *g) { - dSafeNormalize3(g->p); + dReal *p = g->p; + dReal l = dCalcVectorLengthSquare3(p); + if (l > dEpsilon) + { + dScaleVector4(p, dRecipSqrt(l)); + } + else + { + p[0] = 1; + p[1] = 0; + p[2] = 0; + p[3] = 0; + } } @@ -59,7 +71,19 @@ dxGeom (space,0) p[0] = a; p[1] = b; p[2] = c; - p[3] = dSafeNormalize3(p) ? d : 0; + p[3] = d; + dReal l = dCalcVectorLengthSquare3(p); + if (l > dEpsilon) + { + dScaleVector4(p, dRecipSqrt(l)); + } + else + { + p[0] = 1; + p[1] = 0; + p[2] = 0; + p[3] = 0; + } } void dxPlane::computeAABB() @@ -144,10 +168,25 @@ dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d) void dGeomPlaneSetParams (dGeomID g, dReal a, dReal b, dReal c, dReal d) { dUASSERT (g && g->type == dPlaneClass,"argument not a plane"); - ((dxPlane*)g)->p[0] = a; - ((dxPlane*)g)->p[1] = b; - ((dxPlane*)g)->p[2] = c; - ((dxPlane*)g)->p[3] = dSafeNormalize3(((dxPlane*)g)->p) ? d : 0; + dReal* p = ((dxPlane*)g)->p; + p[0] = a; + p[1] = b; + p[2] = c; + p[3] = d; + + dReal l = dCalcVectorLengthSquare3(p); + if (l > dEpsilon) + { + dScaleVector4(p, dRecipSqrt(l)); + } + else + { + p[0] = 1; + p[1] = 0; + p[2] = 0; + p[3] = 0; + } + dGeomMoved (g); } diff --git a/trunk/unmanaged/ubODE-OpenSim/ode/src/ray.cpp b/trunk/unmanaged/ubODE-OpenSim/ode/src/ray.cpp index 6e4148b8..ac04fdf1 100644 --- a/trunk/unmanaged/ubODE-OpenSim/ode/src/ray.cpp +++ b/trunk/unmanaged/ubODE-OpenSim/ode/src/ray.cpp @@ -120,24 +120,27 @@ void dGeomRaySet (dGeomID g, dReal px, dReal py, dReal pz, { dUASSERT (g && g->type == dRayClass,"argument not a ray"); + dxPosR *rayPosR = g->GetRecomputePosR(); + + dReal* pos = rayPosR->pos; + pos[0] = px; + pos[1] = py; + pos[2] = pz; + dVector3 n; n[0] = dx; n[1] = dy; n[2] = dz; dNormalize3(n); - dReal* R = g->final_posr->R; + + dReal* R = rayPosR->R; R[2] = n[0]; R[6] = n[1]; R[10] = n[2]; - dReal* pos = g->final_posr->pos; - pos[0] = px; - pos[1] = py; - pos[2] = pz; dGeomMoved (g); } - void dGeomRayGet (dGeomID g, dVector3 start, dVector3 dir) { dUASSERT (g && g->type == dRayClass,"argument not a ray");