diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-04-13 09:11:34 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-04-13 09:11:34 +0400 |
commit | 13e0d22d8941feadad46882390f3aaf51a0278cf (patch) | |
tree | d88ec50d45ec513bcea3849eb83f87402852664f /source | |
parent | 92fd18e5c2861f3b87df099a35b87807b50ff78d (diff) |
a lot of work in a few small changes to improve penetration depth. and some fixes in shaders from Charlie.
Diffstat (limited to 'source')
6 files changed, 176 insertions, 22 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 408b909a625..d994fe2a7d1 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -309,12 +309,13 @@ static void GetRGB(short type, // ------------------------------------ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* mface, MCol* mmcol, int lightlayer, Object* blenderobj ) { + //this needs some type of manager BL_Material *material = new BL_Material(); - //initBL_Material(material); + int numchan = -1; bool validmat = (mat!=0); - bool using_facetexture = false; - + bool validface = (mesh->tface && tface); + short type = 0; if( validmat ) type = 1; // material color @@ -336,10 +337,21 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* numchan = getNumTexChannels(mat); int valid_index = 0; - bool facetex = ((mat->mode & MA_FACETEXTURE) && (mesh->tface && tface) ); - - numchan = numchan>MAXTEX?MAXTEX:(numchan>=0&& facetex)?numchan+1:numchan; - + // use the face texture if + // 1) it is set in the buttons + // 2) we have a face texture and a material but no valid texture in slot 1 + bool facetex = false; + if(validface && mat->mode &MA_FACETEXTURE) + facetex = true; + if(validface && !mat->mtex[0]) + facetex = true; + if(validface && mat->mtex[0]) { + MTex *tmp = mat->mtex[0]; + if(!tmp->tex || tmp->tex && !tmp->tex->ima ) + facetex = true; + } + numchan = numchan>MAXTEX?MAXTEX:numchan; + // foreach MTex for(int i=0; i<numchan; i++) { // use face tex @@ -355,9 +367,18 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* material->mapping[i].mapping |= USEREFL; else material->mapping[i].mapping |= USEUV; - i++; + if(material->ras_mode & USE_LIGHT) + material->ras_mode &= ~USE_LIGHT; + if(tface->mode & TF_LIGHT) + material->ras_mode |= USE_LIGHT; + valid_index++; } + else { + material->img[i] = 0; + material->texname[i] = ""; + } + continue; } mttmp = getImageFromMaterial( mat, i ); @@ -496,7 +517,7 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* material->amb = mat->amb; // set alpha testing without z-sorting - if( ((mesh->tface && tface ) && (!tface->transp)) && mat->mode & MA_ZTRA) { + if( ( validface && (!tface->transp)) && mat->mode & MA_ZTRA) { // sets the RAS_IPolyMaterial::m_flag |RAS_FORCEALPHA // this is so we don't have the overhead of the z-sorting code material->ras_mode|=ALPHA_TEST; @@ -510,7 +531,11 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* else { int valid = 0; // check for tface tex to fallback on - if( mesh->tface && tface ){ + if( validface ){ + + // no light bugfix + if(tface->mode) material->ras_mode |= USE_LIGHT; + material->img[0] = (Image*)(tface->tpage); // ------------------------ if(material->img[0]) { @@ -537,7 +562,7 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, TFace* tface, MFace* } MT_Point2 uv[4]; - if( mesh->tface && tface ) { + if( validface ) { material->ras_mode |= !( (tface->flag & TF_HIDE) || diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 4a664589871..ce0809628ce 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -470,6 +470,9 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) MT_Matrix4x4 view; rasty->GetViewMatrix(view); + if(mAttr==SHD_TANGENT) + ms.m_mesh->SetMeshModified(true); + BL_UniformVecDef::iterator it; for(it = mPreDef.begin(); it!= mPreDef.end(); it++) { diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 8f3a6a2470c..82f035c4763 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -676,6 +676,16 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, #include "CollisionShapes/TriangleMeshShape.h" #include "CollisionShapes/BvhTriangleMeshShape.h" + #ifdef WIN32 +#if _MSC_VER >= 1310 +//only use SIMD Hull code under Win32 +#define USE_HULL 1 + +#include "NarrowPhaseCollision/Hull.h" + +#endif //_MSC_VER +#endif //WIN32 + static GEN_Map<GEN_HashedPtr,CollisionShape*> map_gamemesh_to_bulletshape; @@ -1010,6 +1020,33 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, bm->SetMargin(0.06); +#ifdef TEST_SIMD_HULL + if (bm->IsPolyhedral()) + { + PolyhedralConvexShape* polyhedron = static_cast<PolyhedralConvexShape*>(bm); + if (!polyhedron->m_optionalHull) + { + //first convert vertices in 'Point3' format + int numPoints = polyhedron->GetNumVertices(); + Point3* points = new Point3[numPoints+1]; + //first 4 points should not be co-planar, so add central point to satisfy MakeHull + points[0] = Point3(0.f,0.f,0.f); + + SimdVector3 vertex; + for (int p=0;p<numPoints;p++) + { + polyhedron->GetVertex(p,vertex); + points[p+1] = Point3(vertex.getX(),vertex.getY(),vertex.getZ()); + } + + Hull* hull = Hull::MakeHull(numPoints+1,points); + polyhedron->m_optionalHull = hull; + } + + } +#endif //TEST_SIMD_HULL + + ci.m_collisionShape = bm; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index e4d0e49d5e8..ff0880b5c2e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -17,6 +17,10 @@ #include "ConstraintSolver/OdeConstraintSolver.h" #include "ConstraintSolver/SimpleConstraintSolver.h" +#ifdef USE_PROFILE +//profiling/timings +#include "quickprof.h" +#endif //USE_PROFILE #include "IDebugDraw.h" @@ -299,7 +303,9 @@ CcdPhysicsEnvironment::CcdPhysicsEnvironment(CollisionDispatcher* dispatcher,Bro :m_scalingPropagated(false), m_numIterations(10), m_ccdMode(0), -m_solverType(-1) +m_solverType(-1), +m_profileTimings(0), +m_enableSatCollisionDetection(false) { if (!dispatcher) @@ -450,13 +456,43 @@ void CcdPhysicsEnvironment::beginFrame() } + bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) { +#ifdef USE_PROFILE + //toggle Profiler + if ( m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_ProfileTimings) + { + if (!m_profileTimings) + { + m_profileTimings = 1; + // To disable profiling, simply comment out the following line. + static int counter = 0; + + char filename[128]; + sprintf(filename,"quickprof_bullet_timings%i.csv",counter++); + Profiler::init(filename, Profiler::BLOCK_CYCLE_SECONDS);//BLOCK_TOTAL_MICROSECONDS + + } + } else + { + if (m_profileTimings) + { + m_profileTimings = 0; + Profiler::destroy(); + } + } +#endif //USE_PROFILE + + + if (!SimdFuzzyZero(timeStep)) { -#define SPLIT_TIMESTEP 1 +// define this in blender, the stepsize is 30 hertz, 60 hertz works much better + #define SPLIT_TIMESTEP 1 + #ifdef SPLIT_TIMESTEP proceedDeltaTimeOneStep(0.5f*timeStep); proceedDeltaTimeOneStep(0.5f*timeStep); @@ -467,6 +503,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) { //todo: interpolate } + return true; } /// Perform an integration step of duration 'timeStep'. @@ -485,6 +522,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } +#ifdef USE_PROFILE + Profiler::beginBlock("SyncMotionStates"); +#endif //USE_PROFILE //this is needed because scaling is not known in advance, and scaling has to propagate to the shape @@ -494,7 +534,11 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) m_scalingPropagated = true; } +#ifdef USE_PROFILE + Profiler::endBlock("SyncMotionStates"); + Profiler::beginBlock("predictIntegratedTransform"); +#endif //USE_PROFILE { // std::vector<CcdPhysicsController*>::iterator i; @@ -516,6 +560,11 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } } + +#ifdef USE_PROFILE + Profiler::endBlock("predictIntegratedTransform"); +#endif //USE_PROFILE + BroadphaseInterface* scene = GetBroadphase(); @@ -524,8 +573,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) // - - +#ifdef USE_PROFILE + Profiler::beginBlock("DispatchAllCollisionPairs"); +#endif //USE_PROFILE + int numsubstep = m_numIterations; @@ -533,14 +584,16 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) DispatcherInfo dispatchInfo; dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; + dispatchInfo.m_enableSatConvex = m_enableSatCollisionDetection; scene->DispatchAllCollisionPairs(*GetDispatcher(),dispatchInfo);///numsubstep,g); +#ifdef USE_PROFILE + Profiler::endBlock("DispatchAllCollisionPairs"); +#endif //USE_PROFILE - - int numRigidBodies = m_controllers.size(); m_collisionWorld->UpdateActivationState(); @@ -548,6 +601,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) //contacts +#ifdef USE_PROFILE + Profiler::beginBlock("SolveConstraint"); +#endif //USE_PROFILE //solve the regular constraints (point 2 point, hinge, etc) @@ -557,7 +613,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) // // constraint solving // - + int i; int numConstraints = m_constraints.size(); @@ -574,6 +630,10 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } + +#ifdef USE_PROFILE + Profiler::endBlock("SolveConstraint"); +#endif //USE_PROFILE //solve the vehicles @@ -625,12 +685,18 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) m_solver, m_debugDrawer); +#ifdef USE_PROFILE + Profiler::beginBlock("BuildAndProcessIslands"); +#endif //USE_PROFILE + /// solve all the contact points and contact friction GetDispatcher()->BuildAndProcessIslands(numRigidBodies,&solverCallback); +#ifdef USE_PROFILE + Profiler::endBlock("BuildAndProcessIslands"); + Profiler::beginBlock("proceedToTransform"); - - +#endif //USE_PROFILE { @@ -803,9 +869,20 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) } +#ifdef USE_PROFILE + Profiler::endBlock("proceedToTransform"); + + Profiler::beginBlock("SyncMotionStates"); +#endif //USE_PROFILE SyncMotionStates(timeStep); +#ifdef USE_PROFILE + Profiler::endBlock("SyncMotionStates"); + + Profiler::endProfilingCycle(); +#endif //USE_PROFILE + #ifdef NEW_BULLET_VEHICLE_SUPPORT //sync wheels for vehicles diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 311e74eaad8..116e3d984df 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -35,8 +35,11 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment int m_numIterations; int m_ccdMode; int m_solverType; - + int m_profileTimings; + bool m_enableSatCollisionDetection; + ContactSolverInfo m_solverInfo; + public: CcdPhysicsEnvironment(CollisionDispatcher* dispatcher=0, BroadphaseInterface* broadphase=0); @@ -131,6 +134,15 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment const CollisionDispatcher* GetDispatcher() const; + bool IsSatCollisionDetectionEnabled() const + { + return m_enableSatCollisionDetection; + } + + void EnableSatCollisionDetection(bool enableSat) + { + m_enableSatCollisionDetection = enableSat; + } int GetNumControllers(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 5fd5ad595d4..7270a6d2a99 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -84,7 +84,7 @@ void RAS_ListSlot::SetModified(bool mod) if(mod && !(m_flag & LIST_MODIFY)) { spit("Modifying list (" << m_list << ")"); m_flag = m_flag &~ LIST_END; - m_flag |= LIST_MODIFY; + m_flag |= LIST_STREAM; } } |