BVB Source Codes

CRYENGINE Show PhysCallbacks.h Source code

Return Download CRYENGINE: download PhysCallbacks.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   PhysCallbacks.h
  5. //  Created:     14/11/2006 by Anton.
  6. //  Description:
  7. // -------------------------------------------------------------------------
  8. //  History:
  9. //
  10. ////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef __PhysCallbacks_h__
  13. #define __PhysCallbacks_h__
  14. #pragma once
  15.  
  16. #include <CryPhysics/IDeferredCollisionEvent.h>
  17.  
  18. class CPhysCallbacks : public Cry3DEngineBase
  19. {
  20. public:
  21.         static void Init();
  22.         static void Done();
  23.  
  24.         static int  OnFoliageTouched(const EventPhys* pEvent);
  25.         static int  OnPhysStateChange(const EventPhys* pEvent);
  26.         //static int OnPhysAreaChange(const EventPhys *pEvent);
  27. };
  28.  
  29. class CPhysStreamer : public IPhysicsStreamer
  30. {
  31. public:
  32.         virtual int CreatePhysicalEntity(void* pForeignData, int iForeignData, int iForeignFlags);
  33.         virtual int DestroyPhysicalEntity(IPhysicalEntity* pent) { return 1; }
  34.         virtual int CreatePhysicalEntitiesInBox(const Vec3& boxMin, const Vec3& boxMax);
  35.         virtual int DestroyPhysicalEntitiesInBox(const Vec3& boxMin, const Vec3& boxMax);
  36. };
  37.  
  38. // Deferred physics event object implementing CPhysCallbacks::OnCollision
  39. class CDeferredCollisionEventOnPhysCollision : public IDeferredPhysicsEvent, public Cry3DEngineBase
  40. {
  41. public:
  42.         virtual ~CDeferredCollisionEventOnPhysCollision();
  43.  
  44.         // Factory create function to pass to CDeferredPhysicsManager::HandleEvent
  45.         static IDeferredPhysicsEvent* CreateCollisionEvent(const EventPhys* pCollisionEvent);
  46.  
  47.         // Entry function to register as event handler with physics
  48.         static int OnCollision(const EventPhys* pEvent);
  49.  
  50.         // == IDeferredPhysicsEvent interface == //
  51.         virtual void                                     Start();
  52.         virtual void                                     Execute();
  53.         virtual void                                     ExecuteAsJob();
  54.         virtual int                                      Result(EventPhys*);
  55.         virtual void                                     Sync();
  56.         virtual bool                                     HasFinished();
  57.  
  58.         virtual IDeferredPhysicsEvent::DeferredEventType GetType() const { return PhysCallBack_OnCollision; }
  59.         virtual EventPhys*                               PhysicsEvent()  { return &m_CollisionEvent; }
  60.  
  61.         void*                                            operator new(size_t);
  62.         void                                             operator delete(void*);
  63.  
  64. private:
  65.         // Private constructor, only allow creating by the factory function(which is used by the deferred physics event manager
  66.         CDeferredCollisionEventOnPhysCollision(const EventPhysCollision* pCollisionEvent);
  67.  
  68.         // == Functions implementing the event logic == //
  69.         void RayTraceVegetation();
  70.         void TestCollisionWithRenderMesh();
  71.         void FinishTestCollisionWithRenderMesh();
  72.         void PostStep();
  73.         void AdjustBulletVelocity();
  74.         void UpdateFoliage();
  75.  
  76.         // == utility functions == //
  77.         void MarkFinished(int nResult);
  78.  
  79.         // == state variables to sync the asynchron execution == //
  80.         JobManager::SJobState m_jobStateRayInter;
  81.         JobManager::SJobState m_jobStateOnCollision;
  82.  
  83.         volatile bool         m_bTaskRunning;
  84.  
  85.         // == members for internal state of the event == //
  86.         bool m_bHit;                              // did  the RayIntersection hit something
  87.         bool m_bFinished;                         // did an early out happen and we are finished with computation
  88.         bool m_bPierceable;                       // remember if we are hitting a pierceable object
  89.         int  m_nResult;                           // result value of the event(0 or 1)
  90.         CDeferredCollisionEventOnPhysCollision* m_pNextEvent;
  91.         int  m_nWaitForPrevEvent;
  92.  
  93.         // == internal data == //
  94.         EventPhysCollision      m_CollisionEvent;               // copy of the original physics event
  95.         SRayHitInfo             m_HitInfo;                      // RayIntersection result data
  96.         _smart_ptr<IRenderMesh> m_pRenderMesh;                  // Rendermesh to use for RayIntersection
  97.         bool                    m_bDecalPlacementTestRequested; // check if decal can be placed here
  98.         _smart_ptr<IMaterial>   m_pMaterial;                    // Material for IMaterial
  99.         bool                    m_bNeedMeshThreadUnLock;        // remeber if we need to unlock a rendermesh
  100.  
  101.         // == members to store values over functions == //
  102.         Matrix34 m_worldTM;
  103.         Matrix33 m_worldRot;
  104.         int*     m_pMatMapping;
  105.         int      m_nMats;
  106.  
  107.         // == States for ThreadTask and AsyncRayIntersection == //
  108.         SIntersectionData m_RayIntersectionData;
  109.  
  110. };
  111.  
  112. #endif // __PhysCallbacks_h__
  113.  
downloadPhysCallbacks.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top