afxResidueMgr.h
Engine/source/afx/afxResidueMgr.h
Classes:
class
Detailed Description
1 2 3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames 5// Copyright (C) 2015 Faust Logic, Inc. 6// 7// Permission is hereby granted, free of charge, to any person obtaining a copy 8// of this software and associated documentation files (the "Software"), to 9// deal in the Software without restriction, including without limitation the 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// sell copies of the Software, and to permit persons to whom the Software is 12// furnished to do so, subject to the following conditions: 13// 14// The above copyright notice and this permission notice shall be included in 15// all copies or substantial portions of the Software. 16// 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// IN THE SOFTWARE. 24// 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 26 27#ifndef _AFX_RESIDUE_MGR_H_ 28#define _AFX_RESIDUE_MGR_H_ 29 30//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 31 32class afxZodiacData; 33class afxModel; 34 35//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 36// afxResidueMgr 37// 38// Manage transient objects in the world. 39 40class afxResidueMgr : public GameBase 41{ 42 43 typedef GameBase Parent; 44 45 enum { 46 ZODIAC, 47 MODEL 48 }; 49 50 struct Residue 51 { 52 struct ZodiacParams 53 { 54 F32 pos_x, pos_y, pos_z; 55 F32 rad, vrange_dn, vrange_up; 56 U8 r,g,b,a; 57 F32 ang; 58 bool on_terrain; 59 }; 60 61 union ResidueParams 62 { 63 ZodiacParams zodiac; 64 }; 65 66 union ResidueData 67 { 68 afxZodiacData* zodiac; 69 afxModel* model; 70 SimObject* simobject; 71 }; 72 73 74 U32 type; 75 ResidueData data; 76 ResidueParams params; 77 U32 fade_time; 78 U32 stop_time; 79 F32 fade; 80 81 Residue* next; 82 }; 83 84 class ResidueList 85 { 86 Vector<Residue*> m_array_a; 87 Vector<Residue*> m_array_b; 88 89 Vector<Residue*>* m_array; 90 Vector<Residue*>* m_scratch_array; 91 bool m_dirty; 92 S32 m_pending; 93 94 void swap_array_ptrs(); 95 void free_residue(Residue*); 96 97 public: 98 /*C*/ ResidueList(); 99 /*D*/ ~<a href="/coding/class/classafxresiduemgr/#classafxresiduemgr_1afc5c95213a4b89a471bb4d58aa60fd4f">ResidueList</a>(); 100 101 void clear(); 102 S32 size() { return m_array->size(); } 103 bool empty() { return m_array->empty(); } 104 void sortIfDirty() { if (m_dirty) sort(); } 105 106 void sort(); 107 void fadeAndCull(U32 now); 108 void stripMatchingObjects(SimObject* db, bool del_notify=false); 109 void add(Residue*); 110 111 void manage(); 112 113 U32 findPendingBestBump(U32 look_max=256); 114 void bumpPending(); 115 116 static int QSORT_CALLBACK compare_residue(const void* p1, const void* p2); 117 }; 118 119 friend class ResidueList; 120 121private: 122 enum { FREE_POOL_BLOCK_SIZE = 256 }; 123 124 static afxResidueMgr* the_mgr; 125 126 static U32 m_max_residue_objs; 127 static bool enabled; 128 129 ResidueList m_managed; 130 131 Vector<Residue*> m_free_pool_blocks; 132 Residue* m_next_free; 133 134 Residue* alloc_free_pool_block(); 135 Residue* alloc_residue(); 136 void free_residue(Residue*); 137 138 void bump_residue(); 139 void add_residue(Residue*); 140 static void add_zodiac(F32 dur, F32 fade_dur, afxZodiacData*, const Point3F& pos, F32 rad, 141 const Point2F& vrange, const LinearColorF& col, F32 ang, bool on_terrain); 142 143protected: 144 void deleteResidueObject(SimObject* obj, bool del_notify=false); 145 146 void manage_residue(const Residue* r); 147 148 bool requires_delete_tracking(Residue*); 149 void enable_delete_tracking(Residue*); 150 void disable_delete_tracking(Residue*); 151 152public: 153 /*C*/ afxResidueMgr(); 154 /*D*/ ~afxResidueMgr(); 155 156 void cleanup(); 157 virtual void onDeleteNotify(SimObject *obj); 158 159public: 160 void residueAdvanceTime(); 161 162 // ZODIAC 163 static void add_terrain_zodiac(F32 dur, F32 fade_dur, afxZodiacData*, const Point3F& pos, F32 rad, 164 const LinearColorF& col, F32 ang); 165 static void add_interior_zodiac(F32 dur, F32 fade_dur, afxZodiacData*, const Point3F& pos, F32 rad, 166 const Point2F& vrange, const LinearColorF& col, F32 ang); 167 168 // MODEL 169 static void add(F32 dur, F32 fade_dur, afxModel*); 170 171 static afxResidueMgr* getMaster() { return the_mgr; } 172 static void setMaster(afxResidueMgr* m) { the_mgr = m; } 173 174 DECLARE_CONOBJECT(afxResidueMgr); 175 DECLARE_CATEGORY("AFX"); 176}; 177 178//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 179 180#endif // _AFX_RESIDUE_MGR_H_ 181