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 #include "../../idlib/precompiled.h"
32 #include "../Game_local.h"
34 CLASS_DECLARATION( idForce, idForce_Constant )
39 idForce_Constant::idForce_Constant
42 idForce_Constant::idForce_Constant( void ) {
51 idForce_Constant::~idForce_Constant
54 idForce_Constant::~idForce_Constant( void ) {
59 idForce_Constant::Save
62 void idForce_Constant::Save( idSaveGame *savefile ) const {
63 savefile->WriteVec3( force );
64 savefile->WriteInt( id );
65 savefile->WriteVec3( point );
70 idForce_Constant::Restore
73 void idForce_Constant::Restore( idRestoreGame *savefile ) {
74 // Owner needs to call SetPhysics!!
75 savefile->ReadVec3( force );
76 savefile->ReadInt( id );
77 savefile->ReadVec3( point );
82 idForce_Constant::SetPosition
85 void idForce_Constant::SetPosition( idPhysics *physics, int id, const idVec3 &point ) {
86 this->physics = physics;
93 idForce_Constant::SetForce
96 void idForce_Constant::SetForce( const idVec3 &force ) {
102 idForce_Constant::SetPhysics
105 void idForce_Constant::SetPhysics( idPhysics *physics ) {
106 this->physics = physics;
111 idForce_Constant::Evaluate
114 void idForce_Constant::Evaluate( int time ) {
121 p = physics->GetOrigin( id ) + point * physics->GetAxis( id );
123 physics->AddForce( id, p, force );
128 idForce_Constant::RemovePhysics
131 void idForce_Constant::RemovePhysics( const idPhysics *phys ) {
132 if ( physics == phys ) {