Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 20, 2008, 5:40:38 PM (17 years ago)
Author:
rgrieder
Message:

Downgraded Bullet to latest tagged version: 2.72
That should give us more stability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h

    r1963 r1972  
    6363                END
    6464        };};
    65 
     65       
    6666        ///eVSolver : velocities solvers
    6767        struct  eVSolver { enum _ {
     
    6969                END
    7070        };};
    71 
     71       
    7272        ///ePSolver : positions solvers
    7373        struct  ePSolver { enum _ {
     
    7878                END
    7979        };};
    80 
     80       
    8181        ///eSolverPresets
    8282        struct  eSolverPresets { enum _ {
     
    8686                END
    8787        };};
    88 
     88       
    8989        ///eFeature
    9090        struct  eFeature { enum _ {
     
    9595                END
    9696        };};
    97 
     97       
    9898        typedef btAlignedObjectArray<eVSolver::_>       tVSolverArray;
    9999        typedef btAlignedObjectArray<ePSolver::_>       tPSolverArray;
    100 
     100       
    101101        //
    102102        // Flags
    103103        //
    104 
     104       
    105105        ///fCollision
    106106        struct fCollision { enum _ {
     
    108108                SDF_RS  =       0x0001, ///SDF based rigid vs soft
    109109                CL_RS   =       0x0002, ///Cluster vs convex rigid vs soft
    110 
     110               
    111111                SVSmask =       0x00f0, ///Rigid versus soft mask               
    112112                VF_SS   =       0x0010, ///Vertex vs face soft vs soft handling
     
    116116                END
    117117        };};
    118 
     118       
    119119        ///fMaterial
    120120        struct fMaterial { enum _ {
     
    124124                END
    125125        };};
    126 
     126               
    127127        //
    128128        // API Types
    129129        //
    130 
     130       
    131131        /* sRayCast             */
    132132        struct sRayCast
     
    135135                eFeature::_     feature;        /// feature type
    136136                int                     index;          /// feature index
    137                 btScalar        fraction;               /// time of impact fraction (rayorg+(rayto-rayfrom)*fraction)
    138         };
    139 
     137                btScalar        time;           /// time of impact (rayorg+raydir*time)
     138        };
     139       
    140140        /* ImplicitFn   */
    141141        struct  ImplicitFn
     
    143143                virtual btScalar        Eval(const btVector3& x)=0;
    144144        };
    145 
     145       
    146146        //
    147147        // Internal types
     
    181181                int                                             m_flags;                // Flags
    182182        };
    183 
     183               
    184184        /* Feature              */
    185185        struct  Feature : Element
     
    297297                btScalar                                        m_matching;
    298298                bool                                            m_collide;
    299                 Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
     299                                                                        Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
    300300        };
    301301        /* Impulse              */
     
    308308                Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0)       {}
    309309                Impulse                                         operator -() const
    310                 {
     310                        {
    311311                        Impulse i=*this;
    312312                        i.m_velocity=-i.m_velocity;
    313313                        i.m_drift=-i.m_drift;
    314314                        return(i);
    315                 }
     315                        }
    316316                Impulse                                         operator*(btScalar x) const
    317                 {
     317                        {
    318318                        Impulse i=*this;
    319319                        i.m_velocity*=x;
    320320                        i.m_drift*=x;
    321321                        return(i);
    322                 }
     322                        }
    323323        };
    324324        /* Body                 */
     
    327327                Cluster*                m_soft;
    328328                btRigidBody*                            m_rigid;
    329                 Body() : m_soft(0),m_rigid(0)                           {}
    330                 Body(Cluster* p) : m_soft(p),m_rigid(0) {}
    331                 Body(btRigidBody* p) : m_soft(0),m_rigid(p)     {}
     329                                                                        Body() : m_soft(0),m_rigid(0)                           {}
     330                                                                        Body(Cluster* p) : m_soft(p),m_rigid(0) {}
     331                                                                        Body(btRigidBody* p) : m_soft(0),m_rigid(p)     {}
    332332                void                                            activate() const
    333                 {
     333                        {
    334334                        if(m_rigid) m_rigid->activate();
    335                 }
     335                        }
    336336                const btMatrix3x3&                      invWorldInertia() const
    337                 {
     337                        {
    338338                        static const btMatrix3x3        iwi(0,0,0,0,0,0,0,0,0);
    339339                        if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
    340340                        if(m_soft)      return(m_soft->m_invwi);
    341341                        return(iwi);
    342                 }
     342                        }
    343343                btScalar                                        invMass() const
    344                 {
     344                        {
    345345                        if(m_rigid) return(m_rigid->getInvMass());
    346346                        if(m_soft)      return(m_soft->m_imass);
    347347                        return(0);
    348                 }
     348                        }
    349349                const btTransform&                      xform() const
    350                 {
     350                        {
    351351                        static const btTransform        identity=btTransform::getIdentity();           
    352352                        if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
    353353                        if(m_soft)      return(m_soft->m_framexform);
    354354                        return(identity);
    355                 }
     355                        }
    356356                btVector3                                       linearVelocity() const
    357                 {
     357                        {
    358358                        if(m_rigid) return(m_rigid->getLinearVelocity());
    359359                        if(m_soft)      return(m_soft->m_lv);
    360360                        return(btVector3(0,0,0));
    361                 }
     361                        }
    362362                btVector3                                       angularVelocity(const btVector3& rpos) const
    363                 {                       
     363                        {                       
    364364                        if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
    365365                        if(m_soft)      return(cross(m_soft->m_av,rpos));
    366366                        return(btVector3(0,0,0));
    367                 }
     367                        }
    368368                btVector3                                       angularVelocity() const
    369                 {                       
     369                        {                       
    370370                        if(m_rigid) return(m_rigid->getAngularVelocity());
    371371                        if(m_soft)      return(m_soft->m_av);
    372372                        return(btVector3(0,0,0));
    373                 }
     373                        }
    374374                btVector3                                       velocity(const btVector3& rpos) const
    375                 {
     375                        {
    376376                        return(linearVelocity()+angularVelocity(rpos));
    377                 }
     377                        }
    378378                void                                            applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
    379                 {
     379                        {
    380380                        if(m_rigid)     m_rigid->applyImpulse(impulse,rpos);
    381381                        if(m_soft)      btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
    382                 }
     382                        }
    383383                void                                            applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
    384                 {
     384                        {
    385385                        if(m_rigid)     m_rigid->applyImpulse(impulse,rpos);
    386386                        if(m_soft)      btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
    387                 }               
     387                        }               
    388388                void                                            applyImpulse(const Impulse& impulse,const btVector3& rpos) const
    389                 {
     389                        {
    390390                        if(impulse.m_asVelocity)        applyVImpulse(impulse.m_velocity,rpos);
    391391                        if(impulse.m_asDrift)           applyDImpulse(impulse.m_drift,rpos);
    392                 }
     392                        }
    393393                void                                            applyVAImpulse(const btVector3& impulse) const
    394                 {
     394                        {
    395395                        if(m_rigid)     m_rigid->applyTorqueImpulse(impulse);
    396396                        if(m_soft)      btSoftBody::clusterVAImpulse(m_soft,impulse);
    397                 }
     397                        }
    398398                void                                            applyDAImpulse(const btVector3& impulse) const
    399                 {
     399                        {
    400400                        if(m_rigid)     m_rigid->applyTorqueImpulse(impulse);
    401401                        if(m_soft)      btSoftBody::clusterDAImpulse(m_soft,impulse);
    402                 }
     402                        }
    403403                void                                            applyAImpulse(const Impulse& impulse) const
    404                 {
     404                        {
    405405                        if(impulse.m_asVelocity)        applyVAImpulse(impulse.m_velocity);
    406406                        if(impulse.m_asDrift)           applyDAImpulse(impulse.m_drift);
    407                 }
     407                        }
    408408                void                                            applyDCImpulse(const btVector3& impulse) const
    409                 {
     409                        {
    410410                        if(m_rigid)     m_rigid->applyCentralImpulse(impulse);
    411411                        if(m_soft)      btSoftBody::clusterDCImpulse(m_soft,impulse);
    412                 }
     412                        }
    413413        };
    414414        /* Joint                */
     
    421421                };};
    422422                struct Specs
    423                 {
    424                         Specs() : erp(1),cfm(1),split(1) {}
     423                        {
     424                                                Specs() : erp(1),cfm(1),split(1) {}
    425425                        btScalar        erp;
    426426                        btScalar        cfm;
    427427                        btScalar        split;
    428                 };
     428                        };
    429429                Body                                            m_bodies[2];
    430430                btVector3                                       m_refs[2];
     
    437437                bool                                            m_delete;
    438438                virtual                                         ~Joint() {}
    439                 Joint() : m_delete(false) {}
     439                                                                        Joint() : m_delete(false) {}
    440440                virtual void                            Prepare(btScalar dt,int iterations);
    441441                virtual void                            Solve(btScalar dt,btScalar sor)=0;
     
    447447        {
    448448                struct Specs : Joint::Specs
    449                 {
     449                        {
    450450                        btVector3       position;
    451                 };             
     451                        };             
    452452                btVector3                                       m_rpos[2];
    453453                void                                            Prepare(btScalar dt,int iterations);
     
    460460        {
    461461                struct IControl
    462                 {
     462                        {
    463463                        virtual void                    Prepare(AJoint*)                                {}
    464464                        virtual btScalar                Speed(AJoint*,btScalar current) { return(current); }
    465465                        static IControl*                Default()                                               { static IControl def;return(&def); }
    466                 };
     466                        };
    467467                struct Specs : Joint::Specs
    468                 {
    469                         Specs() : icontrol(IControl::Default()) {}
     468                        {
     469                                                Specs() : icontrol(IControl::Default()) {}
    470470                        btVector3       axis;
    471471                        IControl*       icontrol;
    472                 };             
     472                        };             
    473473                btVector3                                       m_axis[2];
    474474                IControl*                                       m_icontrol;
     
    533533                btScalar                                updmrg;                 // Update margin
    534534        };     
    535         /// RayFromToCaster takes a ray from, ray to (instead of direction!)
    536         struct  RayFromToCaster : btDbvt::ICollide
    537         {
    538                 btVector3                       m_rayFrom;
    539                 btVector3                       m_rayTo;
    540                 btVector3                       m_rayNormalizedDirection;
    541                 btScalar                        m_mint;
    542                 Face*                           m_face;
    543                 int                                     m_tests;
    544                 RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
     535        /* RayCaster    */
     536        struct  RayCaster : btDbvt::ICollide
     537                {
     538                btVector3                       o;
     539                btVector3                       d;
     540                btScalar                        mint;
     541                Face*   face;
     542                int                                     tests;
     543                                                                RayCaster(const btVector3& org,const btVector3& dir,btScalar mxt);
    545544                void                                    Process(const btDbvtNode* leaf);
    546 
    547                 static inline btScalar  rayFromToTriangle(const btVector3& rayFrom,
    548                         const btVector3& rayTo,
    549                         const btVector3& rayNormalizedDirection,
    550                         const btVector3& a,
    551                         const btVector3& b,
    552                         const btVector3& c,
    553                         btScalar maxt=SIMD_INFINITY);
    554         };
     545                static inline btScalar  rayTriangle(const btVector3& org,
     546                                                                                        const btVector3& dir,
     547                                                                                        const btVector3& a,
     548                                                                                        const btVector3& b,
     549                                                                                        const btVector3& c,
     550                                                                                        btScalar maxt=SIMD_INFINITY);
     551                };
    555552
    556553        //
     
    598595        btDbvt                                  m_cdbvt;                // Clusters tree
    599596        tClusterArray                   m_clusters;             // Clusters
    600 
     597               
    601598        //
    602599        // Api
    603600        //
    604 
     601       
    605602        /* ctor                                                                                                                                 */
    606603        btSoftBody(     btSoftBodyWorldInfo* worldInfo,int node_count,
    607                 const btVector3* x,
    608                 const btScalar* m);
     604                                const btVector3* x,
     605                                const btScalar* m);
    609606        /* dtor                                                                                                                                 */
    610607        virtual ~btSoftBody();
     
    626623                int node1) const;
    627624        bool                            checkLink(      const Node* node0,
    628                 const Node* node1) const;
     625                                                                        const Node* node1) const;
    629626        /* Check for existring face                                                                                             */
    630627        bool                            checkFace(      int node0,
    631                 int node1,
    632                 int node2) const;
     628                                                                        int node1,
     629                                                                        int node2) const;
    633630        /* Append material                                                                                                              */
    634631        Material*                       appendMaterial();
    635632        /* Append note                                                                                                                  */
    636633        void                            appendNote(     const char* text,
    637                 const btVector3& o,
    638                 const btVector4& c=btVector4(1,0,0,0),
    639                 Node* n0=0,
    640                 Node* n1=0,
    641                 Node* n2=0,
    642                 Node* n3=0);
     634                                                                        const btVector3& o,
     635                                                                        const btVector4& c=btVector4(1,0,0,0),
     636                                                                        Node* n0=0,
     637                                                                        Node* n1=0,
     638                                                                        Node* n2=0,
     639                                                                        Node* n3=0);
    643640        void                            appendNote(     const char* text,
    644                 const btVector3& o,
    645                 Node* feature);
     641                                                                        const btVector3& o,
     642                                                                        Node* feature);
    646643        void                            appendNote(     const char* text,
    647                 const btVector3& o,
    648                 Link* feature);
     644                                                                        const btVector3& o,
     645                                                                        Link* feature);
    649646        void                            appendNote(     const char* text,
    650                 const btVector3& o,
    651                 Face* feature);
     647                                                                        const btVector3& o,
     648                                                                        Face* feature);
    652649        /* Append node                                                                                                                  */
    653650        void                            appendNode(     const btVector3& x,btScalar m);
     
    655652        void                            appendLink(int model=-1,Material* mat=0);
    656653        void                            appendLink(     int node0,
    657                 int node1,
    658                 Material* mat=0,
    659                 bool bcheckexist=false);
     654                                                                        int node1,
     655                                                                        Material* mat=0,
     656                                                                        bool bcheckexist=false);
    660657        void                            appendLink(     Node* node0,
    661                 Node* node1,
    662                 Material* mat=0,
    663                 bool bcheckexist=false);
     658                                                                        Node* node1,
     659                                                                        Material* mat=0,
     660                                                                        bool bcheckexist=false);
    664661        /* Append face                                                                                                                  */
    665662        void                            appendFace(int model=-1,Material* mat=0);
    666663        void                            appendFace(     int node0,
    667                 int node1,
    668                 int node2,
    669                 Material* mat=0);
     664                                                                        int node1,
     665                                                                        int node2,
     666                                                                        Material* mat=0);
    670667        /* Append anchor                                                                                                                */
    671668        void                            appendAnchor(   int node,
    672                 btRigidBody* body);
     669                                                                                btRigidBody* body);
    673670        /* Append linear joint                                                                                                  */
    674671        void                            appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
     
    683680        /* Add force (or gravity) to a node of the body                                                 */
    684681        void                            addForce(               const btVector3& force,
    685                 int node);
     682                                                                                int node);
    686683        /* Add velocity to the entire body                                                                              */
    687684        void                            addVelocity(    const btVector3& velocity);
     
    692689        /* Add velocity to a node of the body                                                                   */
    693690        void                            addVelocity(    const btVector3& velocity,
    694                 int node);
     691                                                                                int node);
    695692        /* Set mass                                                                                                                             */
    696693        void                            setMass(                int node,
    697                 btScalar mass);
     694                                                                                btScalar mass);
    698695        /* Get mass                                                                                                                             */
    699696        btScalar                        getMass(                int node) const;
     
    702699        /* Set total mass (weighted by previous masses)                                                 */
    703700        void                            setTotalMass(   btScalar mass,
    704                 bool fromfaces=false);
     701                                                                                bool fromfaces=false);
    705702        /* Set total density                                                                                                    */
    706703        void                            setTotalDensity(btScalar density);
     
    715712        /* Set current state as pose                                                                                    */
    716713        void                            setPose(                bool bvolume,
    717                 bool bframe);
     714                                                                                bool bframe);
    718715        /* Return the volume                                                                                                    */
    719716        btScalar                        getVolume() const;
     
    735732        /* Generate bending constraints based on distance in the adjency graph  */
    736733        int                                     generateBendingConstraints(     int distance,
    737                 Material* mat=0);
     734                                                                                                        Material* mat=0);
    738735        /* Randomize constraints to reduce solver bias                                                  */
    739736        void                            randomizeConstraints();
     
    748745        bool                            cutLink(int node0,int node1,btScalar position);
    749746        bool                            cutLink(const Node* node0,const Node* node1,btScalar position);
    750 
    751         ///Ray casting using rayFrom and rayTo in worldspace, (not direction!)
    752         bool                            rayTest(const btVector3& rayFrom,
    753                 const btVector3& rayTo,
    754                 sRayCast& results);
     747        /* Ray casting                                                                                                                  */
     748        bool                            rayCast(const btVector3& org,
     749                                                                const btVector3& dir,
     750                                                                sRayCast& results,
     751                                                                btScalar maxtime=SIMD_INFINITY);
    755752        /* Solver presets                                                                                                               */
    756753        void                            setSolver(eSolverPresets::_ preset);
     
    770767        void                            defaultCollisionHandler(btCollisionObject* pco);
    771768        void                            defaultCollisionHandler(btSoftBody* psb);
    772 
     769               
    773770        //
    774771        // Cast
    775772        //
    776 
     773               
    777774        static const btSoftBody*        upcast(const btCollisionObject* colObj)
    778775        {
     
    802799        void                            pointersToIndices();
    803800        void                            indicesToPointers(const int* map=0);
    804 
    805         int                                     rayTest(const btVector3& rayFrom,const btVector3& rayTo,
    806                 btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
     801        int                                     rayCast(const btVector3& org,const btVector3& dir,
     802                                                                btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
    807803        void                            initializeFaceTree();
    808804        btVector3                       evaluateCom() const;
     
    827823        static psolver_t        getSolver(ePSolver::_ solver);
    828824        static vsolver_t        getSolver(eVSolver::_ solver);
    829 
     825       
    830826};
    831827
Note: See TracChangeset for help on using the changeset viewer.