2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __GAME_BRITTLEFRACTURE_H__
30 #define __GAME_BRITTLEFRACTURE_H__
34 ===============================================================================
36 B-rep Brittle Fracture - Static entity using the boundary representation
37 of the render model which can fracture.
39 ===============================================================================
42 typedef struct shard_s {
43 idClipModel * clipModel;
44 idFixedWinding winding;
45 idList<idFixedWinding *> decals;
46 idList<bool> edgeHasNeighbour;
47 idList<struct shard_s *> neighbours;
48 idPhysics_RigidBody physicsObj;
55 class idBrittleFracture : public idEntity {
58 CLASS_PROTOTYPE( idBrittleFracture );
60 idBrittleFracture( void );
61 virtual ~idBrittleFracture( void );
63 void Save( idSaveGame *savefile ) const;
64 void Restore( idRestoreGame *savefile );
68 virtual void Present( void );
69 virtual void Think( void );
70 virtual void ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
71 virtual void AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
72 virtual void AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName );
73 virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
75 void ProjectDecal( const idVec3 &point, const idVec3 &dir, const int time, const char *damageDefName );
76 bool IsBroken( void ) const;
79 EVENT_PROJECT_DECAL = idEntity::EVENT_MAXEVENTS,
84 virtual void ClientPredictionThink( void );
85 virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
89 const idMaterial * material;
90 const idMaterial * decalMaterial;
93 float maxShatterRadius;
94 float minShatterRadius;
95 float linearVelocityScale;
96 float angularVelocityScale;
108 idPhysics_StaticMulti physicsObj;
109 idList<shard_t *> shards;
111 bool disableFracture;
114 mutable int lastRenderEntityUpdate;
115 mutable bool changed;
117 bool UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const;
118 static bool ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView );
120 void AddShard( idClipModel *clipModel, idFixedWinding &w );
121 void RemoveShard( int index );
122 void DropShard( shard_t *shard, const idVec3 &point, const idVec3 &dir, const float impulse, const int time );
123 void Shatter( const idVec3 &point, const idVec3 &impulse, const int time );
124 void DropFloatingIslands( const idVec3 &point, const idVec3 &impulse, const int time );
126 void Fracture_r( idFixedWinding &w );
127 void CreateFractures( const idRenderModel *renderModel );
128 void FindNeighbours( void );
130 void Event_Activate( idEntity *activator );
131 void Event_Touch( idEntity *other, trace_t *trace );
134 #endif /* !__GAME_BRITTLEFRACTURE_H__ */