Revision: 15661
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15661
Author:   bdiego
Date:     2008-07-20 23:51:00 +0200 (Sun, 20 Jul 2008)

Log Message:
-----------
branches/blender-2.47

Merge from trunk:
        Revision: 15640
        Revision: 15651
        Revision: 15652
        Revision: 15653
        Revision: 15658

Modified Paths:
--------------
    branches/blender-2.47/source/blender/blenkernel/intern/lattice.c
    branches/blender-2.47/source/blender/blenkernel/intern/particle_system.c
    branches/blender-2.47/source/blender/render/intern/source/shadeoutput.c
    branches/blender-2.47/source/blender/src/drawobject.c
    
branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
    branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.h
    branches/blender-2.47/source/gameengine/Ketsji/KX_GameObject.cpp
    
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsController.h
    
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h

Modified: branches/blender-2.47/source/blender/blenkernel/intern/lattice.c
===================================================================
--- branches/blender-2.47/source/blender/blenkernel/intern/lattice.c    
2008-07-20 21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/blender/blenkernel/intern/lattice.c    
2008-07-20 21:51:00 UTC (rev 15661)
@@ -915,7 +915,10 @@
                mti->deformVerts(md, ob, NULL, vertexCos, numVerts);
        }
 
-       if (vertexCos) {
+       /* always displist to make this work like derivedmesh */
+       if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
+       
+       {
                DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
                dl->type = DL_VERTS;
                dl->parts = 1;

Modified: 
branches/blender-2.47/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/blender-2.47/source/blender/blenkernel/intern/particle_system.c    
2008-07-20 21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/blender/blenkernel/intern/particle_system.c    
2008-07-20 21:51:00 UTC (rev 15661)
@@ -2797,7 +2797,10 @@
                                epart= epsys->part;
                                pd= epart->pd;
                                totepart= epsys->totpart;
-
+                               
+                               if(totepart <= 0)
+                                       continue;
+                               
                                if(pd->forcefield==PFIELD_HARMONIC){
                                        /* every particle is mapped to only one 
harmonic effector particle */
                                        p= pa_no%epsys->totpart;

Modified: 
branches/blender-2.47/source/blender/render/intern/source/shadeoutput.c
===================================================================
--- branches/blender-2.47/source/blender/render/intern/source/shadeoutput.c     
2008-07-20 21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/blender/render/intern/source/shadeoutput.c     
2008-07-20 21:51:00 UTC (rev 15661)
@@ -1379,6 +1379,8 @@
                }
                
                /* specularity */
+               shadfac[3]*= phongcorr; /* note, shadfac not allowed to be 
stored nonlocal */
+               
                if(shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & 
LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) {
                        
                        if(!(passflag & (SCE_PASS_COMBINED|SCE_PASS_SPEC)));

Modified: branches/blender-2.47/source/blender/src/drawobject.c
===================================================================
--- branches/blender-2.47/source/blender/src/drawobject.c       2008-07-20 
21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/blender/src/drawobject.c       2008-07-20 
21:51:00 UTC (rev 15661)
@@ -1199,7 +1199,12 @@
        int use_wcol= 0;
 
        lt= (ob==G.obedit)?editLatt:ob->data;
+       
+       /* now we default make displist, this will modifiers work for non 
animated case */
+       if(ob->disp.first==NULL)
+               lattice_calc_modifiers(ob);
        dl= find_displist(&ob->disp, DL_VERTS);
+       
        if(ob==G.obedit) {
                cpack(0x004000);
                

Modified: 
branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
===================================================================
--- 
branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp   
    2008-07-20 21:09:56 UTC (rev 15660)
+++ 
branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp   
    2008-07-20 21:51:00 UTC (rev 15661)
@@ -13,6 +13,7 @@
 #include "KX_ClientObjectInfo.h"
 
 #include "PHY_IPhysicsEnvironment.h"
+#include "CcdPhysicsEnvironment.h"
 
 
 KX_BulletPhysicsController::KX_BulletPhysicsController (const 
CcdConstructionInfo& ci, bool dyna)
@@ -160,10 +161,17 @@
        btRigidBody *body = GetRigidBody();
        if (body->getActivationState() != DISABLE_SIMULATION)
        {
+               btBroadphaseProxy* handle = body->getBroadphaseHandle();
                m_savedCollisionFlags = body->getCollisionFlags();
+               m_savedMass = GetMass();
+               m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
+               m_savedCollisionFilterMask = handle->m_collisionFilterMask;
                body->setActivationState(DISABLE_SIMULATION);
-               body->setCollisionFlags((btCollisionObject::CF_STATIC_OBJECT)|
-                       ((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:0));
+               GetPhysicsEnvironment()->updateCcdPhysicsController(this, 
+                       0.0,
+                       
btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
+                       btBroadphaseProxy::StaticFilter, 
+                       btBroadphaseProxy::AllFilter ^ 
btBroadphaseProxy::StaticFilter);
        }
 }
 
@@ -172,8 +180,12 @@
        btRigidBody *body = GetRigidBody();
        if (body->getActivationState() == DISABLE_SIMULATION)
        {
+               GetPhysicsEnvironment()->updateCcdPhysicsController(this, 
+                       m_savedMass,
+                       m_savedCollisionFlags,
+                       m_savedCollisionFilterGroup,
+                       m_savedCollisionFilterMask);
                GetRigidBody()->forceActivationState(ACTIVE_TAG);
-               body->setCollisionFlags(m_savedCollisionFlags);
        }
 }
 

Modified: 
branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.h
===================================================================
--- branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.h 
2008-07-20 21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/gameengine/Ketsji/KX_BulletPhysicsController.h 
2008-07-20 21:51:00 UTC (rev 15661)
@@ -9,6 +9,10 @@
 {
 private:
        int m_savedCollisionFlags;
+       short int m_savedCollisionFilterGroup;
+       short int m_savedCollisionFilterMask;
+       MT_Scalar m_savedMass;
+
 public:
 
        KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna);

Modified: branches/blender-2.47/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/blender-2.47/source/gameengine/Ketsji/KX_GameObject.cpp    
2008-07-20 21:09:56 UTC (rev 15660)
+++ branches/blender-2.47/source/gameengine/Ketsji/KX_GameObject.cpp    
2008-07-20 21:51:00 UTC (rev 15661)
@@ -220,6 +220,10 @@
                RemoveParent(scene);
                obj->GetSGNode()->AddChild(GetSGNode());
 
+               if (m_pPhysicsController1) 
+               {
+                       m_pPhysicsController1->SuspendDynamics(true);
+               }
                // Set us to our new scale, position, and orientation
                scale1[0] = scale1[0]/scale2[0];
                scale1[1] = scale1[1]/scale2[1];
@@ -236,10 +240,6 @@
                if (rootlist->RemoveValue(this))
                        // the object was in parent list, decrement ref count 
as it's now removed
                        Release();
-               if (m_pPhysicsController1) 
-               {
-                       m_pPhysicsController1->SuspendDynamics(true);
-               }
        }
 }
 
@@ -617,8 +617,12 @@
 
 void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
 {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController1 && (!GetSGNode() || 
!GetSGNode()->GetSGParent()))
        {
+               // don't update physic controller if the object is a child:
+               // 1) the transformation will not be right
+               // 2) in this case, the physic controller is necessarily a 
static object
+               //    that is updated from the normal kinematic synchronization
                m_pPhysicsController1->setPosition(trans);
        }
 
@@ -630,25 +634,22 @@
 
 void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
 {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController1 && (!GetSGNode() || 
!GetSGNode()->GetSGParent()))
        {
+               // see note above
                m_pPhysicsController1->setOrientation(rot.getRotation());
        }
        if (GetSGNode())
                GetSGNode()->SetLocalOrientation(rot);
-       else
-       {
-               int i;
-               i=0;
-       }
 }
 
 
 
 void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
 {
-       if (m_pPhysicsController1)
+       if (m_pPhysicsController1 && (!GetSGNode() || 
!GetSGNode()->GetSGParent()))
        {
+               // see note above
                m_pPhysicsController1->setScaling(scale);
        }
        

Modified: 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsController.h
===================================================================
--- 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsController.h   
    2008-07-20 21:09:56 UTC (rev 15660)
+++ 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsController.h   
    2008-07-20 21:51:00 UTC (rev 15661)
@@ -106,6 +106,7 @@
        btRigidBody* m_body;
        class PHY_IMotionState*         m_MotionState;
        btMotionState*  m_bulletMotionState;
+       friend class CcdPhysicsEnvironment;     // needed when updating the 
controller
 
 
        void*           m_newClientInfo;
@@ -194,7 +195,6 @@
                        return m_cci.m_collisionFilterMask;
                }
 
-
                virtual void    calcXform() {} ;
                virtual void SetMargin(float margin) {};
                virtual float GetMargin() const {return 0.f;};

Modified: 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
===================================================================
--- 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    2008-07-20 21:09:56 UTC (rev 15660)
+++ 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    2008-07-20 21:51:00 UTC (rev 15661)
@@ -466,7 +466,39 @@
 
 }
 
+void   CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* 
ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, 
short int newCollisionMask)
+{
+       // this function is used when the collisionning group of a controller 
is changed
+       // remove and add the collistioning object
+       btRigidBody* body = ctrl->GetRigidBody();
+       btVector3 inertia;
 
+       m_dynamicsWorld->removeCollisionObject(body);
+       body->setCollisionFlags(newCollisionFlags);
+       body->getCollisionShape()->calculateLocalInertia(newMass, inertia);
+       body->setMassProps(newMass, inertia);
+       m_dynamicsWorld->addCollisionObject(body, newCollisionGroup, 
newCollisionMask);
+       // to avoid nasty interaction, we must update the property of the 
controller as well
+       ctrl->m_cci.m_mass = newMass;
+       ctrl->m_cci.m_collisionFilterGroup = newCollisionGroup;
+       ctrl->m_cci.m_collisionFilterMask = newCollisionMask;
+       ctrl->m_cci.m_collisionFlags = newCollisionFlags;
+}
+
+void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* 
ctrl)
+{
+       std::vector<CcdPhysicsController*>::iterator i =
+               std::find(m_controllers.begin(), m_controllers.end(), ctrl);
+       if (i == m_controllers.end())
+       {
+               btRigidBody* body = ctrl->GetRigidBody();
+               m_dynamicsWorld->addCollisionObject(body, 
+                       ctrl->GetCollisionFilterGroup(), 
ctrl->GetCollisionFilterMask());
+       }
+}
+
+
+
 void   CcdPhysicsEnvironment::beginFrame()
 {
 

Modified: 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
===================================================================
--- 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h  
    2008-07-20 21:09:56 UTC (rev 15660)
+++ 
branches/blender-2.47/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h  
    2008-07-20 21:51:00 UTC (rev 15661)
@@ -183,6 +183,15 @@
 
                void    removeCcdPhysicsController(CcdPhysicsController* ctrl);
 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to