more graphics patches from Snailrose,
authorErwin Coumans <blender@erwincoumans.com>
Sun, 15 Jan 2006 11:34:55 +0000 (11:34 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Sun, 15 Jan 2006 11:34:55 +0000 (11:34 +0000)
remove constraint fixed,
Bullet timestep now subdivides Blender game engine timestep, so it runs 60 hertz,
SphereShape reverted to old style, so no support for non-uniform scaled spheres for now,

23 files changed:
extern/bullet/Bullet/Bullet3_vc8.vcproj
extern/bullet/Bullet/CollisionShapes/SphereShape.cpp
extern/bullet/Bullet/CollisionShapes/SphereShape.h
extern/bullet/BulletDynamics/CollisionDispatch/ConvexConcaveCollisionAlgorithm.cpp
extern/bullet/BulletDynamics/ConstraintSolver/Point2PointConstraint.cpp
extern/bullet/BulletDynamics/ConstraintSolver/Point2PointConstraint.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/BL_Shader.h
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp

index b9046f451e5f2eafdbb35563cc30b87c606ca8db..4c8bc67557bf175bfa5e82fb3c97d83076a3da86 100644 (file)
@@ -42,6 +42,7 @@
                                Optimization="0"
                                AdditionalIncludeDirectories=".;..\LinearMath"
                                PreprocessorDefinitions="_DEBUG;_LIB;WIN32;BUM_INLINED;USE_ALGEBRAIC"
+                               ExceptionHandling="0"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
                                UsePrecompiledHeader="0"
                                RelativePath=".\NarrowPhaseCollision\GjkPairDetector.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\NarrowPhaseCollision\ManifoldPoint.h"
                                >
                                RelativePath=".\CollisionShapes\ConvexShape.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\CollisionShapes\ConvexTriangleCallback.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\CollisionShapes\ConvexTriangleCallback.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\CollisionShapes\CylinderShape.cpp"
                                >
                                RelativePath=".\CollisionShapes\CylinderShape.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\CollisionShapes\EmptyShape.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\CollisionShapes\EmptyShape.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\CollisionShapes\MinkowskiSumShape.cpp"
                                >
                                RelativePath=".\CollisionShapes\StridingMeshInterface.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\CollisionShapes\TriangleCallback.cpp"
+                               >
+                       </File>
                        <File
                                RelativePath=".\CollisionShapes\TriangleCallback.h"
                                >
                                >
                        </File>
                </Filter>
+               <File
+                       RelativePath=".\CollisionShapes\BvhTriangleMeshShape.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath=".\CollisionShapes\BvhTriangleMeshShape.h"
+                       >
+               </File>
+               <File
+                       RelativePath=".\CollisionShapes\OptimizedBvh.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath=".\CollisionShapes\OptimizedBvh.h"
+                       >
+               </File>
+               <File
+                       RelativePath=".\CollisionShapes\TriangleIndexVertexArray.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath=".\CollisionShapes\TriangleIndexVertexArray.h"
+                       >
+               </File>
        </Files>
        <Globals>
        </Globals>
index bbffb8137dec201ab99f5989e609acce1e6a2cf8..37d34a659482b269059b5fcc8ed5dd2a020a8ec0 100644 (file)
@@ -22,14 +22,7 @@ SphereShape ::SphereShape (SimdScalar radius)
 
 SimdVector3    SphereShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const
 {
-       float radius = m_radius - GetMargin();
-
-       SimdScalar len = vec.length2();
-       if (SimdFabs(len) < 0.0001f)
-       {
-               return SimdVector3(m_localScaling[0] * radius,m_localScaling[1]*radius,m_localScaling[2]*radius);
-       } 
-       return vec *  (m_localScaling*(radius / SimdSqrt(len)));
+       return SimdVector3(0.f,0.f,0.f);
 }
 
 SimdVector3    SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
@@ -37,38 +30,31 @@ SimdVector3 SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
        SimdVector3 supVertex;
        supVertex = LocalGetSupportingVertexWithoutMargin(vec);
 
-       if ( GetMargin()!=0.f )
+       SimdVector3 vecnorm = vec;
+       if (SimdFuzzyZero(vecnorm .length2()))
        {
-               SimdVector3 vecnorm = vec;
-               if (vecnorm .length2() == 0.f)
-               {
-                       vecnorm.setValue(-1.f,-1.f,-1.f);
-               } 
-               vecnorm.normalize();
-               supVertex+= GetMargin() * vecnorm;
-       }
+               vecnorm.setValue(-1.f,-1.f,-1.f);
+       } 
+       vecnorm.normalize();
+       supVertex+= GetMargin() * vecnorm;
        return supVertex;
 }
 
-/*
+
 //broken due to scaling
 void SphereShape::GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const
 {
        const SimdVector3& center = t.getOrigin();
-       SimdScalar radius = m_radius;
-       
-       SimdVector3 extent = m_localScaling*radius;
-       extent+= SimdVector3(GetMargin(),GetMargin(),GetMargin());
-
+       SimdVector3 extent(GetMargin(),GetMargin(),GetMargin());
        aabbMin = center - extent;
        aabbMax = center + extent;
 }
-*/
+
 
 
 void   SphereShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia)
 {
-       SimdScalar elem = 0.4f * mass * m_radius*m_radius;
+       SimdScalar elem = 0.4f * mass * GetMargin()*GetMargin();
        inertia[0] = inertia[1] = inertia[2] = elem;
 
 }
\ No newline at end of file
index 82c00ea43ebbcce0bc913c28e6007ad9f12eb934..235af6c4db2ae665eba9d3e1acf80c27831eca2b 100644 (file)
@@ -20,7 +20,7 @@ class SphereShape : public ConvexShape
 
 {
        SimdScalar m_radius;
-
+       
 public:
        SphereShape (SimdScalar radius);
        
@@ -31,7 +31,7 @@ public:
 
        virtual void    CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia);
 
-       //virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const;
+       virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const;
 
        virtual int     GetShapeType() const { return SPHERE_SHAPE_PROXYTYPE; }
 
@@ -40,6 +40,18 @@ public:
        //debugging
        virtual char*   GetName()const {return "SPHERE";}
 
+       virtual void    SetMargin(float margin)
+       {
+               ConvexShape::SetMargin(margin);
+       }
+       virtual float   GetMargin() const
+       {
+               //to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
+               //this means, non-uniform scaling is not supported anymore
+               return m_localScaling[0] * m_radius + ConvexShape::GetMargin();
+       }
+
+
 };
 
 
index f7e41e61824fcb9f1ca21158d5bfa51fbd21618c..a7375e78d384274be9f489f93d3a85cfcdf67bf8 100644 (file)
@@ -153,7 +153,7 @@ void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,Broadp
                
                if (m_convex.IsConvexShape())
                {
-                       float collisionMarginTriangle = 0.02f;//triangleMesh->GetMargin();
+                       float collisionMarginTriangle = triangleMesh->GetMargin();
                                        
                        m_boxTriangleCallback.SetTimeStepAndCounters(timeStep,stepCount, collisionMarginTriangle,useContinuous);
 #ifdef USE_BOX_TRIANGLE
index 9471c1faf7c35473d412267586ff56477cd29cb3..81b75e6e1b8f28c9d408fe25270a611088639083 100644 (file)
 
 
 static RigidBody s_fixed(MassProps(0,SimdVector3(0.f,0.f,0.f)),0.f,0.f,1.f,1.f);
+static int gConstraintId = 1;
 
 Point2PointConstraint::Point2PointConstraint():
 m_rbA(s_fixed),m_rbB(s_fixed)
 {
+       m_constraintId = gConstraintId++;//just create some unique ID for now
+
        s_fixed.setMassProps(0.f,SimdVector3(0.f,0.f,0.f));
 }
 
 Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB)
 :m_rbA(rbA),m_rbB(rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB)
 {
-
+       m_constraintId = gConstraintId++;//just create some unique ID for now
 }
 
 
@@ -32,6 +35,7 @@ Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,const SimdVector3& p
 :m_rbA(rbA),m_rbB(s_fixed),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA))
 {
        s_fixed.setMassProps(0.f,SimdVector3(1e10f,1e10f,1e10f));
+       m_constraintId = gConstraintId++;//just create some unique ID for now
 }
 
 void   Point2PointConstraint::BuildJacobian()
index 82b4dcc83dbc5074b5b5868879f2f81764ebb04e..59b7a5576c46963f1e3d0af0095e5cbfc0b3368d 100644 (file)
@@ -27,6 +27,7 @@ class Point2PointConstraint
        SimdVector3     m_pivotInA;
        SimdVector3     m_pivotInB;
        
+       int     m_constraintId;
 public:
 
        Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB);
@@ -50,6 +51,11 @@ public:
                return m_rbB;
        }
 
+       int GetConstraintId()
+       {
+               return m_constraintId;
+       }
+
 
 };
 
index a2801db7069cb67ddfd48840d26f62e04a037793..10d5e65ed9f4d8762489e0455f9fed53f0374b5d 100644 (file)
@@ -352,7 +352,7 @@ BL_Material* ConvertMaterial(  Mesh* mesh, Material *mat, TFace* tface,  MFace*
                                        material->flag[i] |= ( tface->transp  &TF_ADD   )?CALCALPHA:0;
                                        material->ras_mode|= ( tface->transp  &(TF_ADD | TF_ALPHA))?TRANSP:0;
                                        material->mapping[i].mapping |= ( (material->img[i]->flag & IMA_REFLECT)!=0 )?USEREFL:0;
-                                       material->blend_mode[i] = BLEND_MUL;
+                                       //material->blend_mode[i] = BLEND_MUL;
                                        i++;// skip to the next image
                                        valid_index++;
                                }
@@ -371,12 +371,13 @@ BL_Material* ConvertMaterial(  Mesh* mesh, Material *mat, TFace* tface,  MFace*
                                                        // -----------------------
                                                        if( mttmp->tex->imaflag &TEX_USEALPHA ) {
                                                                material->flag[i]       |= USEALPHA;
-                                                               material->ras_mode      |= TRANSP;
                                                        }
                                                        // -----------------------
                                                        else if( mttmp->tex->imaflag &TEX_CALCALPHA ) {
                                                                material->flag[i]       |= CALCALPHA;
-                                                               material->ras_mode      |= TRANSP;
+                                                       }
+                                                       else if(mttmp->tex->flag &TEX_NEGALPHA) {
+                                                               material->flag[i]       |= USENEGALPHA;
                                                        }
 
                                                        material->color_blend[i] = mttmp->colfac;
@@ -845,8 +846,10 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
 
        // -----------------------------------
        // pre calculate texture generation
-       for(int matid=0; matid<meshobj->NumMaterials(); matid++)
-               meshobj->GetMaterialBucket(matid)->GetPolyMaterial()->OnConstruction();
+       for(RAS_MaterialBucket::Set::iterator mit = meshobj->GetFirstMaterial();
+               mit != meshobj->GetLastMaterial(); ++ mit) {
+               (*mit)->GetPolyMaterial()->OnConstruction();
+       }
        // -----------------------------------
 
 
index 0b8856690d48217b87c8bf46f725d6048a263e1e..cf7534142454b1979fd1a45540f31ff8f6dd7734 100644 (file)
@@ -112,7 +112,8 @@ enum BL_flag
        USEALPHA=4,             // use actual alpha channel
        TEXALPHA=8,             // use alpha combiner functions
        TEXNEG=16,              // negate blending
-       HASIPO=32
+       HASIPO=32,
+       USENEGALPHA=64
 };
 
 // BL_Material::ras_mode
index 369fc58fc50defcc8811c2e3003529d70e12571f..4cc01f820cfdf025d40ffc8e5e2e57e7bfa4048a 100644 (file)
@@ -31,7 +31,7 @@ const bool BL_Shader::Ok()const
        return (mShader !=0 && mOk && mUse);
 }
 
-BL_Shader::BL_Shader(int n, PyTypeObject *T)
+BL_Shader::BL_Shader(PyTypeObject *T)
 :      PyObjectPlus(T),
        mShader(0),
        mVert(0),
@@ -44,15 +44,7 @@ BL_Shader::BL_Shader(int n, PyTypeObject *T)
 {
        // if !RAS_EXT_support._ARB_shader_objects this class will not be used
 
-       mBlending.src   = -1;
-       mBlending.dest  = -1;
-       mBlending.const_color[0] = 0.0;
-       mBlending.const_color[1] = 0.0;
-       mBlending.const_color[2] = 0.0;
-       mBlending.const_color[3] = 1.0;
-
-       for (int i=0; i<MAXTEX; i++)
-       {
+       for (int i=0; i<MAXTEX; i++) {
                mSampler[i].type = 0;
                mSampler[i].pass = 0;
                mSampler[i].unit = -1;
@@ -234,13 +226,6 @@ const uSampler* BL_Shader::getSampler(int i)
        return &mSampler[i];
 }
 
-const uBlending *BL_Shader::getBlending( int pass )
-{
-       return &mBlending;
-}
-
-
-
 void BL_Shader::InitializeSampler(
        int type,
        int unit,
@@ -287,7 +272,6 @@ PyMethodDef BL_Shader::Methods[] =
        KX_PYMETHODTABLE( BL_Shader, setSampler  ),
        KX_PYMETHODTABLE( BL_Shader, setUniformMatrix4 ),
        KX_PYMETHODTABLE( BL_Shader, setUniformMatrix3 ),
-       // KX_PYMETHODTABLE( BL_Shader, setBlending ),
 
        {NULL,NULL} //Sentinel
 };
@@ -368,7 +352,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" )
 
 }
 
-
 KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" )
 {
        return PyInt_FromLong( ( mShader !=0 &&  mOk ) );
@@ -384,21 +367,17 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
        return PyString_FromString(fragProg?fragProg:"");
 }
 
-
 KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
 {
 #ifdef GL_ARB_shader_objects
-       if(mShader==0)
-       {
+       if(mShader==0) {
                PyErr_Format(PyExc_TypeError, "invalid shader object");
                return NULL;
        }
-
        int stat = 0;
        bgl::blValidateProgramARB(mShader);
        bgl::blGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB, &stat);
-
-       return PyInt_FromLong((stat!=0));
+       return PyInt_FromLong(!PrintInfo(stat, mShader, "Validation"));
 #else
        Py_Return;
 #endif//GL_ARB_shader_objects
@@ -446,7 +425,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )
        if(!PyArg_ParseTuple(args, "i", &pass))
                return NULL;
 
-       mPass = pass;
+       mPass = 1;
        Py_Return;
 }
 
@@ -927,16 +906,3 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
        Py_Return;
 #endif//GL_ARB_shader_objects
 }
-
-
-KX_PYMETHODDEF_DOC( BL_Shader, setBlending, "setBlending(src, dest)" )
-{
-       int src, dest;
-       if(PyArg_ParseTuple(args, "ii", &src, &dest))
-       {
-               mBlending.src = src;
-               mBlending.dest = dest;
-               Py_Return;
-       }
-       return NULL;
-}
index 2e08eeb0d70d00551908636dd8a53b9474a25b49..004fd33b6512d2e24121d0268d1818a1bce270bf 100644 (file)
@@ -18,17 +18,6 @@ typedef struct uSampler
 #define SAMP_2D                1
 #define SAMP_CUBE      2
 
-
-// -----------------------------------
-typedef struct uBlending
-{
-       unsigned int pass;
-       int src;        // GL_ blend func values
-       int dest;
-       float const_color[4];
-}uBlending;
-// -----------------------------------
-
 // ----------------
 class BL_Shader : public PyObjectPlus
 {
@@ -41,14 +30,13 @@ private:
        bool                    mOk;
        bool                    mUse;
        uSampler                mSampler[MAXTEX];
-       uBlending               mBlending;
        char*                   vertProg;
        char*                   fragProg;
        bool                    LinkProgram();
        bool                    PrintInfo(int len, unsigned int handle, const char *type);
 
 public:
-       BL_Shader(int n, PyTypeObject *T=&Type);
+       BL_Shader(PyTypeObject *T=&Type);
        virtual ~BL_Shader();
 
        char*           GetVertPtr();
@@ -63,7 +51,6 @@ public:
        // ---
        // access
        const uSampler*         getSampler(int i);
-       const uBlending*        getBlending( int pass );
        const bool                      Ok()const;
 
        unsigned int            GetProg();
@@ -108,8 +95,6 @@ public:
        // these come from within the material buttons
        // sampler2d/samplerCube work
        KX_PYMETHOD_DOC( BL_Shader, setSampler);
-       // user blending funcs
-       KX_PYMETHOD_DOC( BL_Shader, setBlending );
 };
 
 
index 5a41328f489cb3c9f55d3b7e9cc9bf4aeab40487..cbb521338135918ae6e2471d40b3ee20f7d71d1b 100644 (file)
@@ -22,6 +22,7 @@
 #include "KX_Scene.h"
 #include "KX_Light.h"
 #include "KX_GameObject.h"
+#include "KX_MeshProxy.h"
 
 #include "MT_Vector3.h"
 #include "MT_Vector4.h"
@@ -75,7 +76,9 @@ KX_BlenderMaterial::KX_BlenderMaterial(
        mMaterial(data),
        mShader(0),
        mScene(scene),
+       mUserDefBlend(0),
        mPass(0)
+
 {
        ///RAS_EXT_support._ARB_multitexture == true if were here
 
@@ -101,8 +104,8 @@ KX_BlenderMaterial::KX_BlenderMaterial(
        // prevent material bleeding
        for(int i=0; i<mMaterial->num_enabled; i++) {
                m_multimode     +=
-                       (mMaterial->flag[i]     +
-                        mMaterial->blend_mode[i]
+                       ( mMaterial->flag[i]    +
+                         mMaterial->blend_mode[i]
                         );
        }
        m_multimode += mMaterial->IdMode+mMaterial->ras_mode;
@@ -132,11 +135,6 @@ void KX_BlenderMaterial::OnConstruction()
        if(!gTextureDict)
                gTextureDict = PyDict_New();
 */
-       #ifdef GL_ARB_shader_objects
-       if( RAS_EXT_support._ARB_shader_objects )
-               mShader = new BL_Shader( mMaterial->num_enabled );
-       #endif
-
        int i;
        for(i=0; i<mMaterial->num_enabled; i++) {
        bgl::blActiveTextureARB(GL_TEXTURE0_ARB+i);
@@ -149,9 +147,6 @@ void KX_BlenderMaterial::OnConstruction()
                        if(!mTextures[i].InitCubeMap( mMaterial->cubemap[i] ) )
                                spit("unable to initialize image("<<i<<") in "<< 
                                                mMaterial->matname<< ", image will not be available");
-
-                       if( RAS_EXT_support._ARB_shader_objects )
-                               mShader->InitializeSampler(SAMP_CUBE, i, 0, mTextures[i]);
                } 
        
                else {
@@ -160,9 +155,6 @@ void KX_BlenderMaterial::OnConstruction()
                                if( ! mTextures[i].InitFromImage(mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
                                        spit("unable to initialize image("<<i<<") in "<< 
                                                 mMaterial->matname<< ", image will not be available");
-                       
-                               if( RAS_EXT_support._ARB_shader_objects )
-                                       mShader->InitializeSampler(SAMP_2D, i, 0, mTextures[i]);
                        }
                #ifdef GL_ARB_texture_cube_map
                }
@@ -170,6 +162,9 @@ void KX_BlenderMaterial::OnConstruction()
                /*PyDict_SetItemString(gTextureDict, mTextures[i].GetName().Ptr(), PyInt_FromLong(mTextures[i]));*/
        }
        #endif//GL_ARB_multitexture
+
+       mBlendFunc[0] =0;
+       mBlendFunc[1] =0;
 }
 
 void KX_BlenderMaterial::OnExit()
@@ -299,7 +294,15 @@ void KX_BlenderMaterial::setShaderData( bool enable )
                // use a sampler
                bgl::blUniform1iARB(samp->loc, i );
        }
-       glDisable(GL_BLEND);
+
+       if(!mUserDefBlend) {
+               setDefaultBlending();
+       }else
+       {
+               glEnable(GL_BLEND);
+               // tested to be valid enums
+               glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
+       }
 
        #endif//GL_ARB_shader_objects
        #endif//GL_ARB_multitexture
@@ -388,15 +391,16 @@ void KX_BlenderMaterial::setTexData( bool enable )
                #ifdef GL_ARB_texture_cube_map
                }
                #endif//GL_ARB_texture_cube_map
-
-               // if either unit has set blending
-               // and its the last pass
-               lastblend += setBlending( i ); // dry run
-               if(lastblend >0 && i==mMaterial->num_enabled-1)
-                       setBlending( i, true );
-               else if(lastblend == 0 && i==mMaterial->num_enabled-1)
-                       glDisable(GL_BLEND);
        }
+       if(!mUserDefBlend) {
+               setDefaultBlending();
+       }else
+       {
+               glEnable(GL_BLEND);
+               // tested to be valid enums
+               glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
+       }
+
        #endif//GL_ARB_multitexture
 }
 
@@ -587,9 +591,8 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
 
        GLfloat blend_operand           = GL_SRC_COLOR;
-       GLfloat blend_operand_prev      = GL_SRC_COLOR;
+       GLfloat blend_operand_prev  = GL_SRC_COLOR;
 
-       // all sources here are RGB by default
        GLenum combiner = GL_COMBINE_RGB_ARB;
        GLenum source0 = GL_SOURCE0_RGB_ARB;
        GLenum source1 = GL_SOURCE1_RGB_ARB;
@@ -597,6 +600,7 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
        GLenum op0 = GL_OPERAND0_RGB_ARB;
        GLenum op1 = GL_OPERAND1_RGB_ARB;
        GLenum op2 = GL_OPERAND2_RGB_ARB;
+       GLfloat alphaOp = GL_SRC_ALPHA;
 
        // switch to alpha combiners
        if( (mMaterial->flag[textureIndex] &TEXALPHA) ) {
@@ -608,7 +612,6 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
                op1 = GL_OPERAND1_ALPHA_ARB;
                op2 = GL_OPERAND2_ALPHA_ARB;
                blend_operand = GL_SRC_ALPHA;
-               blend_operand_prev = GL_SRC_ALPHA;
                
                // invert
                if(mMaterial->flag[textureIndex] &TEXNEG) {
@@ -618,27 +621,42 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
        }
        else {
                if(mMaterial->flag[textureIndex] &TEXNEG) {
-                       blend_operand_prev = GL_ONE_MINUS_SRC_COLOR;
+                       blend_operand_prev=GL_ONE_MINUS_SRC_COLOR;
                        blend_operand = GL_ONE_MINUS_SRC_COLOR;
                }
        }
-       // on Texture0 GL_PREVIOUS_ARB is the primary color
-       // on Texture1 GL_PREVIOUS_ARB is Texture0 env
+       bool using_alpha = false;
+
+       if(mMaterial->flag[textureIndex] &USEALPHA){
+               alphaOp = GL_ONE_MINUS_SRC_ALPHA;
+               using_alpha=true;
+       }
+       else if(mMaterial->flag[textureIndex] &USENEGALPHA){
+               alphaOp = GL_SRC_ALPHA;
+               using_alpha = true;
+       }
+
        switch( mMaterial->blend_mode[textureIndex] ) {
                case BLEND_MIX:
                        {
                                // ------------------------------
-                               GLfloat base_col[4];
-                               base_col[0]      = base_col[1]  = base_col[2]  = 0.f;
-                               base_col[3]      = 1.f-mMaterial->color_blend[textureIndex];
-                               glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,base_col );
+                               if(!using_alpha) {
+                                       GLfloat base_col[4];
+                                       base_col[0]      = base_col[1]  = base_col[2]  = 0.f;
+                                       base_col[3]      = 1.f-mMaterial->color_blend[textureIndex];
+                                       glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,base_col );
+                               }
                                glTexEnvf(      GL_TEXTURE_ENV, combiner,       GL_INTERPOLATE_ARB);
                                glTexEnvf(      GL_TEXTURE_ENV, source0,        GL_PREVIOUS_ARB);
                                glTexEnvf(      GL_TEXTURE_ENV, op0,            blend_operand_prev );
                                glTexEnvf(      GL_TEXTURE_ENV, source1,        GL_TEXTURE );
                                glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
-                               glTexEnvf(      GL_TEXTURE_ENV, source2,        GL_CONSTANT_ARB );
-                               glTexEnvf(      GL_TEXTURE_ENV, op2,            GL_SRC_ALPHA);
+                               if(!using_alpha)
+                                       glTexEnvf(      GL_TEXTURE_ENV, source2,        GL_CONSTANT_ARB );
+                               else
+                                       glTexEnvf(      GL_TEXTURE_ENV, source2,        GL_TEXTURE );
+
+                               glTexEnvf(      GL_TEXTURE_ENV, op2,            alphaOp);
                        }break;
                case BLEND_MUL: 
                        {
@@ -647,7 +665,10 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
                                glTexEnvf(      GL_TEXTURE_ENV, source0,        GL_PREVIOUS_ARB);
                                glTexEnvf(      GL_TEXTURE_ENV, op0,            blend_operand_prev);
                                glTexEnvf(      GL_TEXTURE_ENV, source1,        GL_TEXTURE );
-                               glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
+                               if(using_alpha)
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            alphaOp);
+                               else
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
                        }break;
                case BLEND_ADD: 
                        {
@@ -656,7 +677,10 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
                                glTexEnvf(      GL_TEXTURE_ENV, source0,        GL_PREVIOUS_ARB );
                                glTexEnvf(      GL_TEXTURE_ENV, op0,            blend_operand_prev );
                                glTexEnvf(      GL_TEXTURE_ENV, source1,        GL_TEXTURE );
-                               glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand );
+                               if(using_alpha)
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            alphaOp);
+                               else
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
                        }break;
                case BLEND_SUB: 
                        {
@@ -674,37 +698,16 @@ void KX_BlenderMaterial::setTextureEnvironment( int textureIndex )
                                glTexEnvf(      GL_TEXTURE_ENV, source0,        GL_PREVIOUS_ARB );
                                glTexEnvf(      GL_TEXTURE_ENV, op0,            blend_operand_prev );
                                glTexEnvf(      GL_TEXTURE_ENV, source1,        GL_TEXTURE );
-                               glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
+                               if(using_alpha)
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            alphaOp);
+                               else
+                                       glTexEnvf(      GL_TEXTURE_ENV, op1,            blend_operand);
                        } break;
        }
+       glTexEnvf(      GL_TEXTURE_ENV, GL_RGB_SCALE_ARB,       1.0);
 #endif //!GL_ARB_texture_env_combine
 }
 
-bool KX_BlenderMaterial::setBlending( int ind, bool enable) 
-{
-       if(!enable) {
-               if(mMaterial->flag[ind] &CALCALPHA )    return true;
-               else if(mMaterial->flag[ind] &USEALPHA )        return true;
-               return false;
-       }
-       else {
-               // additive
-               if(mMaterial->flag[ind] &CALCALPHA ) {
-                       glEnable(GL_BLEND);
-                       glBlendFunc(GL_ONE, GL_ONE);
-                       return true;
-               }
-
-               // use alpha channel
-               else if(mMaterial->flag[ind] &USEALPHA ) {
-                       glEnable(GL_BLEND);
-                       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-                       return true;
-               }
-       }
-       return false;
-}
-
 bool KX_BlenderMaterial::setDefaultBlending()
 {
        if( mMaterial->transp &TF_ADD) {
@@ -873,6 +876,7 @@ PyMethodDef KX_BlenderMaterial::Methods[] =
 {
        KX_PYMETHODTABLE( KX_BlenderMaterial, getShader ),
        KX_PYMETHODTABLE( KX_BlenderMaterial, getMaterialIndex ),
+       KX_PYMETHODTABLE( KX_BlenderMaterial, setBlending ),
 //     KX_PYMETHODTABLE( KX_BlenderMaterial, getTexture ),
 //     KX_PYMETHODTABLE( KX_BlenderMaterial, setTexture ),
 
@@ -922,6 +926,15 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
                return NULL;
        }
        else {
+               if(!mShader) {
+                       mShader = new BL_Shader();
+                       for(int i= 0; i<mMaterial->num_enabled; i++) {
+                               if(mMaterial->mapping[i].mapping & USEENV )
+                                       mShader->InitializeSampler(SAMP_CUBE, i, 0, mTextures[i]);
+                               else
+                                       mShader->InitializeSampler(SAMP_2D, i, 0, mTextures[i]);
+                       }
+               }
                Py_INCREF(mShader);
                return mShader;
        }
@@ -947,3 +960,45 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setTexture , "setTexture( index, tex)")
        return NULL;
 }
 
+static unsigned int GL_array[11] = {
+       GL_ZERO,
+       GL_ONE,
+       GL_SRC_COLOR,
+       GL_ONE_MINUS_SRC_COLOR,
+       GL_DST_COLOR,
+       GL_ONE_MINUS_DST_COLOR,
+       GL_SRC_ALPHA,
+       GL_ONE_MINUS_SRC_ALPHA,
+       GL_DST_ALPHA,
+       GL_ONE_MINUS_DST_ALPHA,
+       GL_SRC_ALPHA_SATURATE
+};
+
+KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( GameLogic.src, GameLogic.dest)")
+{
+       unsigned int b[2];
+       if(PyArg_ParseTuple(args, "ii", &b[0], &b[1]))
+       {
+               bool value_found[2] = {false, false};
+               for(int i=0; i<11; i++)
+               {
+                       if(b[0] == GL_array[i]) {
+                               value_found[0] = true;
+                               mBlendFunc[0] = b[0];
+                       }
+                       if(b[1] == GL_array[i]) {
+                               value_found[1] = true;
+                               mBlendFunc[1] = b[1];
+                       }
+                       if(value_found[0] && value_found[1]) break;
+               }
+               if(!value_found[0] || !value_found[1]) {
+                       PyErr_Format(PyExc_ValueError, "invalid enum.");
+                       return NULL;
+               }
+               mUserDefBlend = true;
+               Py_Return;
+       }
+       return NULL;
+}
+
index 573481448908a495a6af5cc14d8eccf8736980f7..1af4b2550a95a8a10121d1d410ec7e9475e8588e 100644 (file)
@@ -72,6 +72,7 @@ public:
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );
        KX_PYMETHOD_DOC( KX_BlenderMaterial, setTexture );
 
+       KX_PYMETHOD_DOC( KX_BlenderMaterial, setBlending );
        // --------------------------------
        // pre calculate to avoid pops/lag at startup
        virtual void OnConstruction( );
@@ -82,6 +83,9 @@ private:
        KX_Scene*               mScene;
        BL_Texture              mTextures[MAXTEX];              // texture array
        
+       bool                    mUserDefBlend;
+       unsigned int    mBlendFunc[2];
+
        // message centers
        void    setTexData( bool enable );
        void    setShaderData( bool enable );
@@ -90,7 +94,6 @@ private:
        void    setEnvMap( bool val, bool cube=false);
        void    setTexMatrixData(int i);
        bool    setDefaultBlending();
-       bool    setBlending( int ind, bool enable=false );
        void    setObjectMatrixData(int i);
 
        // cleanup stuff
index 2317f9c3a9cae89e4c34624cff2b3e22fb3e321b..0e7ebc6442e4e8b91e39fb89640b0f4dfc367b32 100644 (file)
@@ -362,7 +362,7 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
        {
                if (PHY_GetActiveEnvironment())
                {
-                       PHY_GetActiveEnvironment()->removeConstraint((void *)constraintid);
+                       PHY_GetActiveEnvironment()->removeConstraint(constraintid);
                }
        }
        Py_INCREF(Py_None); return Py_None;
index e2a11c0035eeaa75e1edcceabbbc6ad61e99cadd..ba4f0e55615a6b87bc7fb024eb4ed78c54e60a34 100644 (file)
@@ -277,39 +277,74 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
 #define pprint(x) std::cout << x << std::endl;
        bgl::BL_EXTInfo ext = bgl::RAS_EXT_support;
        bool count=0;
+       bool support=0;
        pprint("Supported Extensions...");
-       #ifdef GL_ARB_shader_objects
-       pprint(" GL_ARB_shader_objects supported?       "<< (ext._ARB_shader_objects?           "yes.":"no."));
+#ifdef GL_ARB_shader_objects
+       pprint(" GL_ARB_shader_objects supported?       "<< (ext._ARB_shader_objects?"yes.":"no."));
        count = 1;
-       #endif
-       #ifdef GL_ARB_vertex_shader
-       pprint(" GL_ARB_vertex_shader supported?        "<< (ext._ARB_vertex_shader?            "yes.":"no."));
-       count = 1;
-       #endif
-       #ifdef GL_ARB_fragment_shader
-       pprint(" GL_ARB_fragment_shader supported?      "<< (ext._ARB_fragment_shader?          "yes.":"no."));
-       count = 1;
-       #endif
-       #ifdef GL_ARB_texture_cube_map
-       pprint(" GL_ARB_texture_cube_map supported?     "<< (ext._ARB_texture_cube_map?         "yes.":"no."));
+#endif
+
+#ifdef GL_ARB_vertex_shader
+       support= ext._ARB_vertex_shader;
+       pprint(" GL_ARB_vertex_shader supported?        "<< (support?"yes.":"no."));
        count = 1;
-       #endif
-       #ifdef GL_EXT_texture3D
-       pprint(" GL_EXT_texture3D supported?            "<< (ext._EXT_texture3D?                        "yes.":"no."));
+       if(support){
+               pprint(" ----------Details----------");
+               int max=0;
+               glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
+               pprint("  Max uniform components." << max);
+
+               glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max);
+               pprint("  Max varying floats." << max);
+
+               glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
+               pprint("  Max vertex texture units." << max);
+       
+               glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
+               pprint("  Max combined texture units." << max);
+               pprint("");
+       }
+#endif
+#ifdef GL_ARB_fragment_shader
+       support=ext._ARB_fragment_shader;
+       pprint(" GL_ARB_fragment_shader supported?      "<< (support?"yes.":"no."));
        count = 1;
-       #endif
-       #ifdef GL_EXT_blend_color
-       pprint(" GL_EXT_blend_color supported?          "<< (ext._EXT_blend_color?                      "yes.":"no."));
+       if(support){
+               pprint(" ----------Details----------");
+               int max=0;
+               glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
+               pprint("  Max uniform components." << max);
+               pprint("");
+       }
+#endif
+#ifdef GL_ARB_texture_cube_map
+       support = ext._ARB_texture_cube_map;
+       pprint(" GL_ARB_texture_cube_map supported?     "<< (support?"yes.":"no."));
        count = 1;
-       #endif
-       #ifdef GL_ARB_multitexture
-       pprint(" GL_ARB_multitexture supported?         "<< (ext._ARB_multitexture?                     "yes.":"no."));
+       if(support){
+               pprint(" ----------Details----------");
+               int size=0;
+               glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size);
+               pprint("  Max cubemap size." << size);
+               pprint("");
+       }
+#endif
+#ifdef GL_ARB_multitexture
+       support = ext._ARB_multitexture;
        count = 1;
-       #endif
-       #ifdef GL_ARB_texture_env_combine
-       pprint(" GL_ARB_texture_env_combine supported?  "<< (ext._ARB_texture_env_combine?      "yes.":"no."));
+       pprint(" GL_ARB_multitexture supported?         "<< (support?"yes.":"no."));
+       if(support){
+               pprint(" ----------Details----------");
+               int units=0;
+               glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units);
+               pprint("  Max texture units available.  " << units);
+               pprint("");
+       }
+#endif
+#ifdef GL_ARB_texture_env_combine
+       pprint(" GL_ARB_texture_env_combine supported?  "<< (ext._ARB_texture_env_combine?"yes.":"no."));
        count = 1;
-       #endif
+#endif
        if(!count)
                pprint("No extenstions are used in this build");
 
@@ -707,6 +742,19 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
        KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND,     BL_ActionActuator::KX_ACT_ACTION_LOOPEND);
        KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY,     BL_ActionActuator::KX_ACT_ACTION_PROPERTY);
        
+       /*8. GL_BlendFunc */
+       KX_MACRO_addTypesToDict(d, BL_ZERO, GL_ZERO);
+       KX_MACRO_addTypesToDict(d, BL_ONE, GL_ONE);
+       KX_MACRO_addTypesToDict(d, BL_SRC_COLOR, GL_SRC_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_DST_COLOR, GL_DST_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA, GL_SRC_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_DST_ALPHA, GL_DST_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA_SATURATE, GL_SRC_ALPHA_SATURATE);
+
        // Check for errors
        if (PyErr_Occurred())
     {
index 46406d5b8e313415ecd0d46d1fc4d66e5df2e1ec..cdf617f1722125b24e3b286942890d873ff11cde 100644 (file)
@@ -192,7 +192,7 @@ void        CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
                        if  ((&p2p->GetRigidBodyA() == ctrl->GetRigidBody() ||
                                (&p2p->GetRigidBodyB() == ctrl->GetRigidBody())))
                        {
-                                removeConstraint(p2p);
+                                removeConstraint(p2p->GetConstraintId());
                                //only 1 constraint per constroller
                                break;
                        }
@@ -209,7 +209,7 @@ void        CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
                        if  ((&p2p->GetRigidBodyA() == ctrl->GetRigidBody() ||
                                (&p2p->GetRigidBodyB() == ctrl->GetRigidBody())))
                        {
-                               removeConstraint(p2p);
+                               removeConstraint(p2p->GetConstraintId());
                                //only 1 constraint per constroller
                                break;
                        }
@@ -301,9 +301,23 @@ void       CcdPhysicsEnvironment::beginFrame()
 
 }
 
-/// Perform an integration step of duration 'timeStep'.
 bool   CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
 {
+
+       if (!SimdFuzzyZero(timeStep))
+       {
+               //Blender runs 30hertz, so subdivide so we get 60 hertz
+               proceedDeltaTimeOneStep(0.5f*timeStep);
+               proceedDeltaTimeOneStep(0.5f*timeStep);
+       } else
+       {
+               //todo: interpolate
+       }
+       return true;
+}
+/// Perform an integration step of duration 'timeStep'.
+bool   CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
+{
        
        
 //     printf("CcdPhysicsEnvironment::proceedDeltaTime\n");
@@ -318,9 +332,6 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
 
 
 
-       //clamp hardcoded for now
-       if (timeStep > 0.02)
-               timeStep = 0.02;
        
        //this is needed because scaling is not known in advance, and scaling has to propagate to the shape
        if (!m_scalingPropagated)
@@ -758,7 +769,9 @@ int                 CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        }
                        
                        m_p2pConstraints.push_back(p2p);
-                       return 0;
+                       
+                       //64 bit systems can't cast pointer to int. could use size_t instead.
+                       return p2p->GetConstraintId();
                        
                        break;
                }
@@ -773,17 +786,24 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
        
 }
 
-void           CcdPhysicsEnvironment::removeConstraint(void* p2p)
+void           CcdPhysicsEnvironment::removeConstraint(int     constraintId)
 {
-       std::vector<Point2PointConstraint*>::iterator i =
-               std::find(m_p2pConstraints.begin(), m_p2pConstraints.end(), 
-                               (Point2PointConstraint *)p2p);
+       std::vector<Point2PointConstraint*>::iterator i;
+               
+               //std::find(m_p2pConstraints.begin(), m_p2pConstraints.end(), 
+               //              (Point2PointConstraint *)p2p);
        
-       if (!(i == m_p2pConstraints.end()) )
-       {
-               std::swap(*i, m_p2pConstraints.back());
-               m_p2pConstraints.pop_back();
-       }
+               for (i=m_p2pConstraints.begin();
+               !(i==m_p2pConstraints.end()); i++)
+               {
+                       Point2PointConstraint* p2p = (*i);
+                       if (p2p->GetConstraintId() == constraintId)
+                       {
+                               std::swap(*i, m_p2pConstraints.back());
+                               m_p2pConstraints.pop_back();
+                               break;
+                       }
+               }
        
 }
 PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
index 6050af2f3c8d5cc9162689d8e5ae9b7e74ec8c23..1b2527aa5bbc3cd414e6af73cf73a8dbbe29a744 100644 (file)
@@ -63,6 +63,8 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
                virtual void            endFrame() {};
                /// Perform an integration step of duration 'timeStep'.
                virtual bool            proceedDeltaTime(double curTime,float timeStep);
+               bool                            proceedDeltaTimeOneStep(float timeStep);
+
                virtual void            setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep){};
                //returns 0.f if no fixed timestep is used
 
@@ -75,7 +77,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
                virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ);
-           virtual void                removeConstraint(void* constraintid);
+           virtual void                removeConstraint(int    constraintid);
 
 
                virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
index 0b6f8a4ded4c09d7ef5488cbf4a104e344ad8932..0532a9a8cf75251ccf36cef0863d6fdf22c1b79b 100644 (file)
@@ -101,7 +101,7 @@ int                 DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ct
 
 }
 
-void           DummyPhysicsEnvironment::removeConstraint(void * constraintid)
+void           DummyPhysicsEnvironment::removeConstraint(int   constraintid)
 {
        if (constraintid)
        {
index 0a359feea6d4a9bdab0f28b38c4a4eb39d93119d..a400459afe68e49d7f245c226b8d9d1d7776ac5d 100644 (file)
@@ -61,7 +61,7 @@ public:
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ);
 
-       virtual void            removeConstraint(void * constraintid);
+       virtual void            removeConstraint(int    constraintid);
        virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
                                                                        float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
 
index 081a2fb979463e91823a9f75ccca905e2cb61a1a..656051be4f55c60ed6fde552ff44816651205796 100644 (file)
@@ -183,7 +183,7 @@ bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate)
        if (!m_frames)
        {
                if (ticrate > 0.)
-                       m_frames = (unsigned int)(curtime*ticrate + 1.0);
+                       m_frames = (unsigned int)(curtime*ticrate) + 1.0;
                else
                        m_frames = (unsigned int)(curtime*65536.0);
        }
@@ -275,7 +275,11 @@ bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate)
                for (i = m_objectList.begin(); i != m_objectList.end(); ++i) 
                        (*i)->interpolate(curtime);
        
-               m_frames = (unsigned int)(curtime*ticrate + 1.0);
+       //only update the m_frames after an actual physics timestep
+               if (num_samples)
+               {
+                       m_frames = (unsigned int)(curtime*ticrate) + 1.0;
+               }
        }
        else
        {
index 8d03fd4b0f4b86b6ffb7acdbd70a5d8171cb065f..ead6dcc010671b190d7310bb5803d766b318533d 100644 (file)
@@ -117,7 +117,7 @@ int SumoPhysicsEnvironment::createConstraint(
        return constraintid;
 }
 
-void SumoPhysicsEnvironment::removeConstraint(void * constraintid)
+void SumoPhysicsEnvironment::removeConstraint(int      constraintid)
 {
        if (constraintid)
        {
index c93e34825b922e8b6c697d561bdde8bb189004f8..e164140716639161145d93456a20ccfe95801694 100644 (file)
@@ -66,7 +66,7 @@ public:
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ);
 
-       virtual void            removeConstraint(void * constraintid);
+       virtual void            removeConstraint(int    constraintid);
        virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
                                                                        float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
 
index 1158563527abc31073be40b50509aca2c32ce929..078f84d4de27cce0fb092706c84e2e5b98f4c23a 100644 (file)
@@ -83,7 +83,7 @@ class PHY_IPhysicsEnvironment
                virtual int                     createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ)=0;
-               virtual void            removeConstraint(void * constraintid)=0;
+               virtual void            removeConstraint(int    constraintid)=0;
 
                virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
                                                                                float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)=0;
index 82a3f23dcf2ca3087a90466ffec83a337f5d49a6..2b47acb2e32a2786b1054390200631ace5c99f60 100644 (file)
@@ -509,7 +509,7 @@ static void LinkExtensions()
        }
 #endif
 
-#ifdef GL_ARB_shader_objects
+#if GL_ARB_shader_objects
        if (QueryExtension("GL_ARB_shader_objects"))
        {
                bgl::blDeleteObjectARB = reinterpret_cast<PFNGLDELETEOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glDeleteObjectARB"));
@@ -562,7 +562,7 @@ static void LinkExtensions()
        }
 #endif
 
-#ifdef GL_ARB_vertex_shader
+#if GL_ARB_vertex_shader
        if (QueryExtension("GL_ARB_vertex_shader"))
        {
                bgl::blBindAttribLocationARB = reinterpret_cast<PFNGLBINDATTRIBLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glBindAttribLocationARB"));