BVB Source Codes

CRYENGINE Show ProceduralBreak.h Source code

Return Download CRYENGINE: download ProceduralBreak.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description:  network breakability: basic information for procedural breaks
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - 22/01/2007   10:34 : Created by Craig Tiller
  11. *************************************************************************/
  12. #ifndef __PROCEDURALBREAK_H__
  13. #define __PROCEDURALBREAK_H__
  14.  
  15. #pragma once
  16.  
  17. #if !NET_USE_SIMPLE_BREAKAGE
  18.  
  19.         #include "DebugBreakage.h"
  20.  
  21.         #define BREAK_HIERARCHICAL_TRACKING 1
  22.  
  23. enum ENetBreakOperation
  24. {
  25.         eNBO_Create = 0, // must be first
  26.         eNBO_Create_NoSpawn,
  27.         eNBO_Update,
  28.         eNBO_Remove,
  29.         eNBO_Remove_NoSpawn,
  30.         eNBO_JointBreak,
  31.         // absorbed a breaktype, step
  32.         eNBO_AbsorbStep,
  33.         #if BREAK_HIERARCHICAL_TRACKING
  34.         // performed a post step, flush relevant joint breaks
  35.         eNBO_PostStep,
  36.         // very special op - once we reach it, we skip over it, but bump the frame count
  37.         eNBO_FrameCounterFinished,
  38.         #endif
  39.         eNBO_NUM_OPERATIONS, // must be last
  40. };
  41.  
  42. static const uint32 OPS_REFERENCING_ENTS     = BIT(eNBO_Create) | BIT(eNBO_Create_NoSpawn) | BIT(eNBO_Update) | BIT(eNBO_Remove) | BIT(eNBO_Remove_NoSpawn) | BIT(eNBO_JointBreak);
  43. static const uint32 OPS_CAUSING_ENTS         = BIT(eNBO_Create) | BIT(eNBO_Update) | BIT(eNBO_Remove) | BIT(eNBO_JointBreak);
  44. static const uint32 OPS_WITH_PARTIDS         = BIT(eNBO_Create) | BIT(eNBO_Create_NoSpawn);
  45. static const uint32 OPS_WITH_NOSPAWN         = BIT(eNBO_Remove);
  46.         #if BREAK_HIERARCHICAL_TRACKING
  47. static const uint32 OPS_JOINT_FRAME_COUNTERS = BIT(eNBO_PostStep) | BIT(eNBO_Remove) | BIT(eNBO_Remove_NoSpawn);
  48. static const uint32 OPS_ADD_OPEN             = BIT(eNBO_Create) | BIT(eNBO_JointBreak);
  49. static const uint32 OPS_REMOVE_OPEN          = BIT(eNBO_Remove) | BIT(eNBO_Remove_NoSpawn);
  50.         #endif
  51.  
  52. struct SProceduralSpawnRec
  53. {
  54.         SProceduralSpawnRec()
  55.                 : op(eNBO_NUM_OPERATIONS)
  56.                 , idxRef(0)
  57.                 , idx(0)
  58.                 , partid(0)
  59.         {}
  60.  
  61.         ENetBreakOperation op;
  62.         int                idxRef;
  63.         int                idx;
  64.         int                partid;
  65.  
  66.         void               SerializeWith(TSerialize ser);
  67. };
  68.  
  69. struct SJointBreakRec
  70. {
  71.         int    idxRef;
  72.         int    id;
  73.         #if BREAK_HIERARCHICAL_TRACKING
  74.         uint16 frame;
  75.         #endif
  76.         int    epicenter;
  77.  
  78.         void   SerializeWith(TSerialize ser);
  79. };
  80.  
  81. struct SJointBreakParticleRec
  82. {
  83.         Vec3 vel;
  84.         void SerializeWith(TSerialize ser);
  85. };
  86.  
  87. template<class T>
  88. struct SProceduralStreamWrapper : public T
  89. {
  90.         SProceduralStreamWrapper() : breakId(-1) {}
  91.         SProceduralStreamWrapper(int bid, const T& rec) : T(rec), breakId(bid) {}
  92.         int breakId;
  93.  
  94.         void SerializeWith(TSerialize ser)
  95.         {
  96.                 LOGBREAK("SProceduralStreamWrapper, %s", ser.IsReading() ? "Reading:" : "Writing");
  97.                 ser.Value("breakId", breakId, 'brId');
  98.                 LOGBREAK("breakId: %d", breakId);
  99.                 T::SerializeWith(ser);
  100.         }
  101. };
  102.  
  103. typedef SProceduralStreamWrapper<SProceduralSpawnRec>    SDeclareProceduralSpawnRec;
  104. typedef SProceduralStreamWrapper<SJointBreakRec>         SDeclareJointBreakRec;
  105. typedef SProceduralStreamWrapper<SJointBreakParticleRec> SDeclareJointBreakParticleRec;
  106.  
  107. struct SProceduralBreak : public IBreakDescriptionInfo
  108. {
  109.         SProceduralBreak() : magicId(0) {}
  110.         int                              magicId;
  111.         DynArray<SJointBreakRec>         jointBreaks;
  112.         DynArray<SProceduralSpawnRec>    spawnRecs;
  113.         DynArray<SJointBreakParticleRec> gibs;
  114.         void AddProceduralSendables(int breakId, INetSendableSink* pSink);
  115. };
  116.  
  117. #endif // !NET_USE_SIMPLE_BREAKAGE
  118.  
  119. #endif
  120.  
downloadProceduralBreak.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