Ignore:
Timestamp:
Aug 17, 2012, 7:41:36 PM (8 years ago)
Author:
touky
Message:

Added Attachment/base logic with working attachment with EasyCharacterController.
Added RayCastResult & a naïve integration for EasyCharacterController.
Enjoy !

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Physics/Include/EasyPhysics.h

    r1764 r1768  
    3535
    3636        friend class EasyConstraint;
     37        friend class Simulation;
    3738
    3839#ifdef HAVE_PHYS_USE_BULLET
     
    4950
    5051        virtual bool CanChangeCollisionChannel() { return (m_rigid_body == NULL); }
     52        virtual mat4 GetTransform();
    5153        virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
    52 private:
     54protected:
    5355        virtual void BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix);
    5456public:
     
    5860        virtual void AddToSimulation(class Simulation* current_simulation);
    5961        virtual void RemoveFromSimulation(class Simulation* current_simulation);
    60         virtual mat4 GetTransform();
    6162
    6263protected:
     
    6465        virtual void SetShapeTo(btCollisionShape* collision_shape);
    6566
    66         virtual btGhostObject* GetGhostObject();
     67        virtual btGhostObject* GetGhostObjectInstance();
    6768
    6869        btCollisionObject*                                                      m_collision_object;
     
    8990
    9091        virtual bool CanChangeCollisionChannel() { return true; }
     92        virtual mat4 GetTransform() { return mat4(1.0f); }
    9193        virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
    9294private:
     
    98100        virtual void AddToSimulation(class Simulation* current_simulation) { }
    99101        virtual void RemoveFromSimulation(class Simulation* current_simulation) { }
    100         virtual mat4 GetTransform() { return mat4(1.0f); }
    101102
    102103        virtual void InitBodyToGhost() { }
     
    123124        virtual void AttachTo(EasyPhysic* NewBase, bool NewBaseLockLocation = true, bool NewBaseLockRotation = true)
    124125        {
    125                 if (NewBase == this || NewBase->m_base_physic == this)
     126                if (NewBase == this || (NewBase && NewBase->m_base_physic == this))
    126127                        return;
    127128
     
    138139                        m_base_lock_rotation = NewBaseLockRotation;
    139140                }
    140                 else
     141                else if (m_base_physic)
    141142                {
    142                         for (int i = 0; i < NewBase->m_based_physic_list.Count(); ++i)
    143                                 if (NewBase->m_based_physic_list[i] == this)
    144                                         NewBase->m_based_physic_list.Remove(i--);
     143                        for (int i = 0; i < m_base_physic->m_based_physic_list.Count(); ++i)
     144                                if (m_base_physic->m_based_physic_list[i] == this)
     145                                        m_base_physic->m_based_physic_list.Remove(i--);
    145146                        m_base_physic = NULL;
    146147                }
Note: See TracChangeset for help on using the changeset viewer.