Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
3.8 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. #ifndef SCENEOBJECT_H
  3. #define SCENEOBJECT_H
  4. #ifdef _WIN32
  5. #pragma once
  6. #endif
  7. #include "scenesystem/iscenesystem.h"
  8. class ISceneObjectDesc;
  9. enum ESceneObjectFlags
  10. {
  11. SCENEOBJECTFLAG_IS_LOADED = 1, // this will go away when we have permanent data - we can't afford to poll all objects.
  12. SCENEOBJECTFLAG_DRAW_IN_PREPASS = 2,
  13. SCENEOBJECTFLAG_DRAW_IN_LIGHTPASS = 4,
  14. SCENEOBJECTFLAG_DRAW_IN_COMBINE_PASS = 8,
  15. SCENEOBJECTFLAG_DRAW_IN_TRANSLUCENT_PASS = 16,
  16. SCENEOBJECTFLAG_DRAW_IN_REFLECTION_PASS = 32,
  17. SCENEOBJECTFLAG_IS_DISABLED = 64,
  18. };
  19. enum ESceneObjectTypeFlags
  20. {
  21. SCENEOBJECTTYPEFLAG_IS_PROCEDURAL = 1, // objects with this set draw via calling the DrawArray entrypoint in the ISceneObjectDesc, not by bundling up meshes
  22. SCENEOBJECTTYPEFLAG_FROM_POOL = 2, // was allocated from our pool
  23. };
  24. class CSceneObjectReference_t // this is what we store in our spatial data structures. 32 bytes
  25. {
  26. public:
  27. VectorAligned m_vecAABBMins;
  28. uint m_nRenderableFlags;
  29. VectorAligned m_vecAABBMaxes;
  30. class CSceneObject *m_pObject;
  31. };
  32. class CSceneObject
  33. {
  34. public:
  35. CSceneObject *m_pNext; // temp for linking objects in list
  36. CSceneObjectReference_t *m_pRefData;
  37. uint8 m_nID; // not unique! - for hashing, etc
  38. uint8 m_nNumDrawPrimitives;
  39. uint8 m_nObjectTypeFlags;
  40. uint8 m_nPad;
  41. HRenderableStrong m_hRenderable;
  42. uint m_nRenderableFlags; // this is a mirror of the flags for objects which are not in hierarchy yet
  43. // temporary so that alex can check in without breaking scenesystem
  44. IMat2 *m_pMaterialHack;
  45. union
  46. {
  47. MaterialDrawDescriptor_t const *m_pDrawPrimitives; // fixed mesh objects have this
  48. void *m_pObjectData; // procedurals and non-fixed meshes get this, and it is used as a sort key
  49. };
  50. template<class T> FORCEINLINE T * ObjectData( void )
  51. {
  52. Assert( m_nNumDrawPrimitives == 0 );
  53. return ( reinterpret_cast< T* >( m_pObjectData ) );
  54. }
  55. matrix3x4_t m_transform;
  56. ISceneObjectDesc *m_pDesc;
  57. FORCEINLINE uint32 GetID( void ) const
  58. {
  59. return m_nID;
  60. }
  61. FORCEINLINE void MirrorFlags( void ) const
  62. {
  63. if ( m_pRefData )
  64. {
  65. m_pRefData->m_nRenderableFlags = m_nRenderableFlags;
  66. }
  67. }
  68. FORCEINLINE bool IsLoaded( void ) const
  69. {
  70. return ( m_nRenderableFlags & SCENEOBJECTFLAG_IS_LOADED ) != 0;
  71. }
  72. FORCEINLINE void SetLoaded( void )
  73. {
  74. m_nRenderableFlags |= SCENEOBJECTFLAG_IS_LOADED;
  75. MirrorFlags();
  76. }
  77. FORCEINLINE void ClearLoaded( void )
  78. {
  79. m_nRenderableFlags &= ~SCENEOBJECTFLAG_IS_LOADED;
  80. MirrorFlags();
  81. }
  82. FORCEINLINE void SetBounds( Vector const &vecMins, Vector const &vecMaxes )
  83. {
  84. g_pSceneSystem->SetObjectBounds( this, vecMins, vecMaxes );
  85. }
  86. };
  87. // particle vertex layout defs - ! to be moved. eventaully all of this will be hidden inside the particles.lib render ops
  88. struct VertexRepeatedStream_t
  89. {
  90. Vector2D m_vecCoord; // -1 1 1 1 1 -1 -1 -1
  91. };
  92. struct VertexUVPos_t
  93. {
  94. Vector m_vecPos;
  95. Vector2D m_vecUV;
  96. };
  97. struct VertexPerParticleStream_t
  98. {
  99. Vector m_vecPos;
  100. float m_flRadius;
  101. VertexColor_t m_color;
  102. };
  103. class CSceneParticleObject : public CSceneObject
  104. {
  105. public:
  106. IMat2 *m_pMaterial; // will go away with particle/mat2 integration
  107. CParticleCollection *m_pParticles;
  108. };
  109. class CSceneMonitorObject : public CSceneObject
  110. {
  111. public:
  112. Vector m_MonitorVerts[4];
  113. HRenderTextureStrong m_hMonitorTexture;
  114. RenderTargetBinding_t m_hRenderTargetBinding;
  115. IMat2 *m_pMaterial;
  116. CFrustum m_frustum;
  117. };
  118. #define DRAWLIST_CHUNKSIZE 1024
  119. class CSceneDrawList
  120. {
  121. public:
  122. CSceneDrawList *m_pNext;
  123. int m_nNumPrimitives;
  124. CMeshDrawPrimitive_t m_drawPrimitives[DRAWLIST_CHUNKSIZE];
  125. };
  126. #endif