doom3-bfg/neo/d3xp/physics/Physics_StaticMulti.cpp

1271 lines
24 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition 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 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
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.
===========================================================================
*/
#pragma hdrstop
#include "precompiled.h"
2012-11-26 18:58:24 +00:00
#include "../Game_local.h"
CLASS_DECLARATION( idPhysics, idPhysics_StaticMulti )
END_CLASS
staticPState_t defaultState;
staticInterpolatePState_t defaultInterpolateState;
/*
================
idPhysics_StaticMulti::idPhysics_StaticMulti
================
*/
idPhysics_StaticMulti::idPhysics_StaticMulti()
{
2012-11-26 18:58:24 +00:00
self = NULL;
hasMaster = false;
isOrientated = false;
2012-11-26 18:58:24 +00:00
defaultState.origin.Zero();
defaultState.axis.Identity();
defaultState.localOrigin.Zero();
defaultState.localAxis.Identity();
2012-11-26 18:58:24 +00:00
defaultInterpolateState.origin.Zero();
defaultInterpolateState.axis = defaultState.axis.ToQuat();
defaultInterpolateState.localAxis = defaultInterpolateState.axis;
defaultInterpolateState.localOrigin.Zero();
2012-11-26 18:58:24 +00:00
current.SetNum( 1 );
current[0] = defaultState;
previous.SetNum( 1 );
previous[0] = defaultInterpolateState;
next.SetNum( 1 );
next[0] = defaultInterpolateState;
clipModels.SetNum( 1 );
clipModels[0] = NULL;
}
/*
================
idPhysics_StaticMulti::~idPhysics_StaticMulti
================
*/
idPhysics_StaticMulti::~idPhysics_StaticMulti()
{
if( self && self->GetPhysics() == this )
{
2012-11-26 18:58:24 +00:00
self->SetPhysics( NULL );
}
idForce::DeletePhysics( this );
for( int i = 0; i < clipModels.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
delete clipModels[i];
}
}
/*
================
idPhysics_StaticMulti::Save
================
*/
void idPhysics_StaticMulti::Save( idSaveGame* savefile ) const
{
2012-11-26 18:58:24 +00:00
int i;
2012-11-26 18:58:24 +00:00
savefile->WriteObject( self );
savefile->WriteInt( current.Num() );
for( i = 0; i < current.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
savefile->WriteVec3( current[i].origin );
savefile->WriteMat3( current[i].axis );
savefile->WriteVec3( current[i].localOrigin );
savefile->WriteMat3( current[i].localAxis );
}
2012-11-26 18:58:24 +00:00
savefile->WriteInt( clipModels.Num() );
for( i = 0; i < clipModels.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
savefile->WriteClipModel( clipModels[i] );
}
savefile->WriteBool( hasMaster );
savefile->WriteBool( isOrientated );
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::Restore
================
*/
void idPhysics_StaticMulti::Restore( idRestoreGame* savefile )
{
2012-11-26 18:58:24 +00:00
int i, num;
savefile->ReadObject( reinterpret_cast<idClass*&>( self ) );
savefile->ReadInt( num );
2012-11-26 18:58:24 +00:00
current.AssureSize( num );
for( i = 0; i < num; i++ )
{
2012-11-26 18:58:24 +00:00
savefile->ReadVec3( current[i].origin );
savefile->ReadMat3( current[i].axis );
savefile->ReadVec3( current[i].localOrigin );
savefile->ReadMat3( current[i].localAxis );
}
savefile->ReadInt( num );
2012-11-26 18:58:24 +00:00
clipModels.SetNum( num );
for( i = 0; i < num; i++ )
{
2012-11-26 18:58:24 +00:00
savefile->ReadClipModel( clipModels[i] );
}
savefile->ReadBool( hasMaster );
savefile->ReadBool( isOrientated );
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::SetSelf
================
*/
void idPhysics_StaticMulti::SetSelf( idEntity* e )
{
2012-11-26 18:58:24 +00:00
assert( e );
self = e;
}
/*
================
idPhysics_StaticMulti::RemoveIndex
================
*/
void idPhysics_StaticMulti::RemoveIndex( int id, bool freeClipModel )
{
if( id < 0 || id >= clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
return;
}
if( clipModels[id] && freeClipModel )
{
2012-11-26 18:58:24 +00:00
delete clipModels[id];
clipModels[id] = NULL;
}
clipModels.RemoveIndex( id );
current.RemoveIndex( id );
}
/*
================
idPhysics_StaticMulti::SetClipModel
================
*/
void idPhysics_StaticMulti::SetClipModel( idClipModel* model, float density, int id, bool freeOld )
{
2012-11-26 18:58:24 +00:00
int i;
2012-11-26 18:58:24 +00:00
assert( self );
if( id >= clipModels.Num() )
{
current.AssureSize( id + 1, defaultState );
clipModels.AssureSize( id + 1, NULL );
2012-11-26 18:58:24 +00:00
}
if( clipModels[id] && clipModels[id] != model && freeOld )
{
2012-11-26 18:58:24 +00:00
delete clipModels[id];
}
clipModels[id] = model;
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
2012-11-26 18:58:24 +00:00
}
for( i = clipModels.Num() - 1; i >= 1; i-- )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
break;
}
}
current.SetNum( i + 1 );
clipModels.SetNum( i + 1 );
// Assure that on first setup, our next/previous is the same as current.
2012-11-26 18:58:24 +00:00
previous.SetNum( current.Num() );
next.SetNum( previous.Num() );
for( int curIdx = 0; curIdx < current.Num(); curIdx++ )
{
2012-11-26 18:58:24 +00:00
previous[curIdx] = ConvertPStateToInterpolateState( current[curIdx] );
previous[curIdx] = next[curIdx];
}
}
/*
================
idPhysics_StaticMulti::GetClipModel
================
*/
idClipModel* idPhysics_StaticMulti::GetClipModel( int id ) const
{
if( id >= 0 && id < clipModels.Num() && clipModels[id] )
{
2012-11-26 18:58:24 +00:00
return clipModels[id];
}
return gameLocal.clip.DefaultClipModel();
}
/*
================
idPhysics_StaticMulti::GetNumClipModels
================
*/
int idPhysics_StaticMulti::GetNumClipModels() const
{
2012-11-26 18:58:24 +00:00
return clipModels.Num();
}
/*
================
idPhysics_StaticMulti::SetMass
================
*/
void idPhysics_StaticMulti::SetMass( float mass, int id )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetMass
================
*/
float idPhysics_StaticMulti::GetMass( int id ) const
{
2012-11-26 18:58:24 +00:00
return 0.0f;
}
/*
================
idPhysics_StaticMulti::SetContents
================
*/
void idPhysics_StaticMulti::SetContents( int contents, int id )
{
2012-11-26 18:58:24 +00:00
int i;
if( id >= 0 && id < clipModels.Num() )
{
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->SetContents( contents );
}
}
else if( id == -1 )
{
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->SetContents( contents );
}
}
}
}
/*
================
idPhysics_StaticMulti::GetContents
================
*/
int idPhysics_StaticMulti::GetContents( int id ) const
{
2012-11-26 18:58:24 +00:00
int i, contents = 0;
if( id >= 0 && id < clipModels.Num() )
{
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
contents = clipModels[id]->GetContents();
}
}
else if( id == -1 )
{
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
contents |= clipModels[i]->GetContents();
}
}
}
return contents;
}
/*
================
idPhysics_StaticMulti::SetClipMask
================
*/
void idPhysics_StaticMulti::SetClipMask( int mask, int id )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetClipMask
================
*/
int idPhysics_StaticMulti::GetClipMask( int id ) const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::GetBounds
================
*/
const idBounds& idPhysics_StaticMulti::GetBounds( int id ) const
{
2012-11-26 18:58:24 +00:00
int i;
static idBounds bounds;
if( id >= 0 && id < clipModels.Num() )
{
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
return clipModels[id]->GetBounds();
}
}
if( id == -1 )
{
2012-11-26 18:58:24 +00:00
bounds.Clear();
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
bounds.AddBounds( clipModels[i]->GetAbsBounds() );
}
}
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
bounds[0] -= clipModels[i]->GetOrigin();
bounds[1] -= clipModels[i]->GetOrigin();
break;
}
}
return bounds;
}
return bounds_zero;
}
/*
================
idPhysics_StaticMulti::GetAbsBounds
================
*/
const idBounds& idPhysics_StaticMulti::GetAbsBounds( int id ) const
{
2012-11-26 18:58:24 +00:00
int i;
static idBounds absBounds;
if( id >= 0 && id < clipModels.Num() )
{
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
return clipModels[id]->GetAbsBounds();
}
}
if( id == -1 )
{
2012-11-26 18:58:24 +00:00
absBounds.Clear();
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
absBounds.AddBounds( clipModels[i]->GetAbsBounds() );
}
}
return absBounds;
}
return bounds_zero;
}
/*
================
idPhysics_StaticMulti::Evaluate
================
*/
bool idPhysics_StaticMulti::Evaluate( int timeStepMSec, int endTimeMSec )
{
2012-11-26 18:58:24 +00:00
int i;
idVec3 masterOrigin;
idMat3 masterAxis;
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
for( i = 0; i < clipModels.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
current[i].origin = masterOrigin + current[i].localOrigin * masterAxis;
if( isOrientated )
{
2012-11-26 18:58:24 +00:00
current[i].axis = current[i].localAxis * masterAxis;
}
else
{
2012-11-26 18:58:24 +00:00
current[i].axis = current[i].localAxis;
}
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
}
}
2012-11-26 18:58:24 +00:00
// FIXME: return false if master did not move
return true;
}
return false;
}
/*
================
idPhysics_StaticMulti::Interpolate
================
*/
bool idPhysics_StaticMulti::Interpolate( const float fraction )
{
2012-11-26 18:58:24 +00:00
// If the sizes don't match, just use the latest version.
// TODO: This might cause visual snapping, is there a better solution?
if( current.Num() != previous.Num() ||
current.Num() != next.Num() )
{
2012-11-26 18:58:24 +00:00
current.SetNum( next.Num() );
for( int i = 0; i < next.Num(); ++i )
{
2012-11-26 18:58:24 +00:00
current[i] = InterpolateStaticPState( next[i], next[i], 1.0f );
}
return true;
}
for( int i = 0; i < current.Num(); ++i )
{
2012-11-26 18:58:24 +00:00
current[i] = InterpolateStaticPState( previous[i], next[i], fraction );
}
2012-11-26 18:58:24 +00:00
return true;
}
/*
================
idPhysics_StaticMulti::UpdateTime
================
*/
void idPhysics_StaticMulti::UpdateTime( int endTimeMSec )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetTime
================
*/
int idPhysics_StaticMulti::GetTime() const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::GetImpactInfo
================
*/
void idPhysics_StaticMulti::GetImpactInfo( const int id, const idVec3& point, impactInfo_t* info ) const
{
2012-11-26 18:58:24 +00:00
memset( info, 0, sizeof( *info ) );
}
/*
================
idPhysics_StaticMulti::ApplyImpulse
================
*/
void idPhysics_StaticMulti::ApplyImpulse( const int id, const idVec3& point, const idVec3& impulse )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::AddForce
================
*/
void idPhysics_StaticMulti::AddForce( const int id, const idVec3& point, const idVec3& force )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::Activate
================
*/
void idPhysics_StaticMulti::Activate()
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::PutToRest
================
*/
void idPhysics_StaticMulti::PutToRest()
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::IsAtRest
================
*/
bool idPhysics_StaticMulti::IsAtRest() const
{
2012-11-26 18:58:24 +00:00
return true;
}
/*
================
idPhysics_StaticMulti::GetRestStartTime
================
*/
int idPhysics_StaticMulti::GetRestStartTime() const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::IsPushable
================
*/
bool idPhysics_StaticMulti::IsPushable() const
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
================
idPhysics_StaticMulti::SaveState
================
*/
void idPhysics_StaticMulti::SaveState()
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::RestoreState
================
*/
void idPhysics_StaticMulti::RestoreState()
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::SetOrigin
================
*/
void idPhysics_StaticMulti::SetOrigin( const idVec3& newOrigin, int id )
{
2012-11-26 18:58:24 +00:00
idVec3 masterOrigin;
idMat3 masterAxis;
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
current[id].localOrigin = newOrigin;
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
current[id].origin = masterOrigin + newOrigin * masterAxis;
}
else
{
2012-11-26 18:58:24 +00:00
current[id].origin = newOrigin;
}
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
}
}
else if( id == -1 )
{
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
Translate( masterOrigin + masterAxis * newOrigin - current[0].origin );
}
else
{
2012-11-26 18:58:24 +00:00
Translate( newOrigin - current[0].origin );
}
}
}
/*
================
idPhysics_StaticMulti::SetAxis
================
*/
void idPhysics_StaticMulti::SetAxis( const idMat3& newAxis, int id )
{
2012-11-26 18:58:24 +00:00
idVec3 masterOrigin;
idMat3 masterAxis;
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
current[id].localAxis = newAxis;
if( hasMaster && isOrientated )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
current[id].axis = newAxis * masterAxis;
}
else
{
2012-11-26 18:58:24 +00:00
current[id].axis = newAxis;
}
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
}
}
else if( id == -1 )
{
2012-11-26 18:58:24 +00:00
idMat3 axis;
idRotation rotation;
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
axis = current[0].axis.Transpose() * ( newAxis * masterAxis );
}
else
{
2012-11-26 18:58:24 +00:00
axis = current[0].axis.Transpose() * newAxis;
}
rotation = axis.ToRotation();
rotation.SetOrigin( current[0].origin );
2012-11-26 18:58:24 +00:00
Rotate( rotation );
}
}
/*
================
idPhysics_StaticMulti::Translate
================
*/
void idPhysics_StaticMulti::Translate( const idVec3& translation, int id )
{
2012-11-26 18:58:24 +00:00
int i;
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
current[id].localOrigin += translation;
current[id].origin += translation;
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
}
}
else if( id == -1 )
{
for( i = 0; i < clipModels.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
current[i].localOrigin += translation;
current[i].origin += translation;
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
}
}
}
}
/*
================
idPhysics_StaticMulti::Rotate
================
*/
void idPhysics_StaticMulti::Rotate( const idRotation& rotation, int id )
{
2012-11-26 18:58:24 +00:00
int i;
idVec3 masterOrigin;
idMat3 masterAxis;
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
current[id].origin *= rotation;
current[id].axis *= rotation.ToMat3();
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
current[id].localAxis *= rotation.ToMat3();
current[id].localOrigin = ( current[id].origin - masterOrigin ) * masterAxis.Transpose();
}
else
{
2012-11-26 18:58:24 +00:00
current[id].localAxis = current[id].axis;
current[id].localOrigin = current[id].origin;
}
if( clipModels[id] )
{
2012-11-26 18:58:24 +00:00
clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
}
}
else if( id == -1 )
{
for( i = 0; i < clipModels.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
current[i].origin *= rotation;
current[i].axis *= rotation.ToMat3();
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
self->GetMasterPosition( masterOrigin, masterAxis );
current[i].localAxis *= rotation.ToMat3();
current[i].localOrigin = ( current[i].origin - masterOrigin ) * masterAxis.Transpose();
}
else
{
2012-11-26 18:58:24 +00:00
current[i].localAxis = current[i].axis;
current[i].localOrigin = current[i].origin;
}
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
}
}
}
}
/*
================
idPhysics_StaticMulti::GetOrigin
================
*/
const idVec3& idPhysics_StaticMulti::GetOrigin( int id ) const
{
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
return current[id].origin;
}
if( clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
return current[0].origin;
}
else
{
2012-11-26 18:58:24 +00:00
return vec3_origin;
}
}
/*
================
idPhysics_StaticMulti::GetAxis
================
*/
const idMat3& idPhysics_StaticMulti::GetAxis( int id ) const
{
if( id >= 0 && id < clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
return current[id].axis;
}
if( clipModels.Num() )
{
2012-11-26 18:58:24 +00:00
return current[0].axis;
}
else
{
2012-11-26 18:58:24 +00:00
return mat3_identity;
}
}
/*
================
idPhysics_StaticMulti::SetLinearVelocity
================
*/
void idPhysics_StaticMulti::SetLinearVelocity( const idVec3& newLinearVelocity, int id )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::SetAngularVelocity
================
*/
void idPhysics_StaticMulti::SetAngularVelocity( const idVec3& newAngularVelocity, int id )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetLinearVelocity
================
*/
const idVec3& idPhysics_StaticMulti::GetLinearVelocity( int id ) const
{
2012-11-26 18:58:24 +00:00
return vec3_origin;
}
/*
================
idPhysics_StaticMulti::GetAngularVelocity
================
*/
const idVec3& idPhysics_StaticMulti::GetAngularVelocity( int id ) const
{
2012-11-26 18:58:24 +00:00
return vec3_origin;
}
/*
================
idPhysics_StaticMulti::SetGravity
================
*/
void idPhysics_StaticMulti::SetGravity( const idVec3& newGravity )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetGravity
================
*/
const idVec3& idPhysics_StaticMulti::GetGravity() const
{
2012-11-26 18:58:24 +00:00
static idVec3 gravity( 0, 0, -g_gravity.GetFloat() );
return gravity;
}
/*
================
idPhysics_StaticMulti::GetGravityNormal
================
*/
const idVec3& idPhysics_StaticMulti::GetGravityNormal() const
{
2012-11-26 18:58:24 +00:00
static idVec3 gravity( 0, 0, -1 );
return gravity;
}
/*
================
idPhysics_StaticMulti::ClipTranslation
================
*/
void idPhysics_StaticMulti::ClipTranslation( trace_t& results, const idVec3& translation, const idClipModel* model ) const
{
2012-11-26 18:58:24 +00:00
memset( &results, 0, sizeof( trace_t ) );
gameLocal.Warning( "idPhysics_StaticMulti::ClipTranslation called" );
}
/*
================
idPhysics_StaticMulti::ClipRotation
================
*/
void idPhysics_StaticMulti::ClipRotation( trace_t& results, const idRotation& rotation, const idClipModel* model ) const
{
2012-11-26 18:58:24 +00:00
memset( &results, 0, sizeof( trace_t ) );
gameLocal.Warning( "idPhysics_StaticMulti::ClipRotation called" );
}
/*
================
idPhysics_StaticMulti::ClipContents
================
*/
int idPhysics_StaticMulti::ClipContents( const idClipModel* model ) const
{
2012-11-26 18:58:24 +00:00
int i, contents;
2012-11-26 18:58:24 +00:00
contents = 0;
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
if( model )
{
2012-11-26 18:58:24 +00:00
contents |= gameLocal.clip.ContentsModel( clipModels[i]->GetOrigin(), clipModels[i], clipModels[i]->GetAxis(), -1,
model->Handle(), model->GetOrigin(), model->GetAxis() );
}
else
{
2012-11-26 18:58:24 +00:00
contents |= gameLocal.clip.Contents( clipModels[i]->GetOrigin(), clipModels[i], clipModels[i]->GetAxis(), -1, NULL );
}
}
}
return contents;
}
/*
================
idPhysics_StaticMulti::DisableClip
================
*/
void idPhysics_StaticMulti::DisableClip()
{
2012-11-26 18:58:24 +00:00
int i;
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Disable();
}
}
}
/*
================
idPhysics_StaticMulti::EnableClip
================
*/
void idPhysics_StaticMulti::EnableClip()
{
2012-11-26 18:58:24 +00:00
int i;
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Enable();
}
}
}
/*
================
idPhysics_StaticMulti::UnlinkClip
================
*/
void idPhysics_StaticMulti::UnlinkClip()
{
2012-11-26 18:58:24 +00:00
int i;
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Unlink();
}
}
}
/*
================
idPhysics_StaticMulti::LinkClip
================
*/
void idPhysics_StaticMulti::LinkClip()
{
2012-11-26 18:58:24 +00:00
int i;
for( i = 0; i < clipModels.Num(); i++ )
{
if( clipModels[i] )
{
2012-11-26 18:58:24 +00:00
clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
}
}
}
/*
================
idPhysics_StaticMulti::EvaluateContacts
================
*/
bool idPhysics_StaticMulti::EvaluateContacts()
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
================
idPhysics_StaticMulti::GetNumContacts
================
*/
int idPhysics_StaticMulti::GetNumContacts() const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::GetContact
================
*/
const contactInfo_t& idPhysics_StaticMulti::GetContact( int num ) const
{
2012-11-26 18:58:24 +00:00
static contactInfo_t info;
memset( &info, 0, sizeof( info ) );
return info;
}
/*
================
idPhysics_StaticMulti::ClearContacts
================
*/
void idPhysics_StaticMulti::ClearContacts()
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::AddContactEntity
================
*/
void idPhysics_StaticMulti::AddContactEntity( idEntity* e )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::RemoveContactEntity
================
*/
void idPhysics_StaticMulti::RemoveContactEntity( idEntity* e )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::HasGroundContacts
================
*/
bool idPhysics_StaticMulti::HasGroundContacts() const
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
================
idPhysics_StaticMulti::IsGroundEntity
================
*/
bool idPhysics_StaticMulti::IsGroundEntity( int entityNum ) const
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
================
idPhysics_StaticMulti::IsGroundClipModel
================
*/
bool idPhysics_StaticMulti::IsGroundClipModel( int entityNum, int id ) const
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
================
idPhysics_StaticMulti::SetPushed
================
*/
void idPhysics_StaticMulti::SetPushed( int deltaTime )
{
2012-11-26 18:58:24 +00:00
}
/*
================
idPhysics_StaticMulti::GetPushedLinearVelocity
================
*/
const idVec3& idPhysics_StaticMulti::GetPushedLinearVelocity( const int id ) const
{
2012-11-26 18:58:24 +00:00
return vec3_origin;
}
/*
================
idPhysics_StaticMulti::GetPushedAngularVelocity
================
*/
const idVec3& idPhysics_StaticMulti::GetPushedAngularVelocity( const int id ) const
{
2012-11-26 18:58:24 +00:00
return vec3_origin;
}
/*
================
idPhysics_StaticMulti::SetMaster
================
*/
void idPhysics_StaticMulti::SetMaster( idEntity* master, const bool orientated )
{
2012-11-26 18:58:24 +00:00
int i;
idVec3 masterOrigin;
idMat3 masterAxis;
if( master )
{
if( !hasMaster )
{
2012-11-26 18:58:24 +00:00
// transform from world space to master space
self->GetMasterPosition( masterOrigin, masterAxis );
for( i = 0; i < clipModels.Num(); i++ )
{
current[i].localOrigin = ( current[i].origin - masterOrigin ) * masterAxis.Transpose();
if( orientated )
{
2012-11-26 18:58:24 +00:00
current[i].localAxis = current[i].axis * masterAxis.Transpose();
}
else
{
2012-11-26 18:58:24 +00:00
current[i].localAxis = current[i].axis;
}
}
hasMaster = true;
isOrientated = orientated;
}
}
else
{
if( hasMaster )
{
2012-11-26 18:58:24 +00:00
hasMaster = false;
}
}
}
/*
================
idPhysics_StaticMulti::GetBlockingInfo
================
*/
const trace_t* idPhysics_StaticMulti::GetBlockingInfo() const
{
2012-11-26 18:58:24 +00:00
return NULL;
}
/*
================
idPhysics_StaticMulti::GetBlockingEntity
================
*/
idEntity* idPhysics_StaticMulti::GetBlockingEntity() const
{
2012-11-26 18:58:24 +00:00
return NULL;
}
/*
================
idPhysics_StaticMulti::GetLinearEndTime
================
*/
int idPhysics_StaticMulti::GetLinearEndTime() const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::GetAngularEndTime
================
*/
int idPhysics_StaticMulti::GetAngularEndTime() const
{
2012-11-26 18:58:24 +00:00
return 0;
}
/*
================
idPhysics_StaticMulti::WriteToSnapshot
================
*/
void idPhysics_StaticMulti::WriteToSnapshot( idBitMsg& msg ) const
{
2012-11-26 18:58:24 +00:00
int i;
idCQuat quat, localQuat;
2012-11-26 18:58:24 +00:00
msg.WriteByte( current.Num() );
for( i = 0; i < current.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
quat = current[i].axis.ToCQuat();
localQuat = current[i].localAxis.ToCQuat();
2012-11-26 18:58:24 +00:00
msg.WriteFloat( current[i].origin[0] );
msg.WriteFloat( current[i].origin[1] );
msg.WriteFloat( current[i].origin[2] );
msg.WriteFloat( quat.x );
msg.WriteFloat( quat.y );
msg.WriteFloat( quat.z );
msg.WriteDeltaFloat( current[i].origin[0], current[i].localOrigin[0] );
msg.WriteDeltaFloat( current[i].origin[1], current[i].localOrigin[1] );
msg.WriteDeltaFloat( current[i].origin[2], current[i].localOrigin[2] );
msg.WriteDeltaFloat( quat.x, localQuat.x );
msg.WriteDeltaFloat( quat.y, localQuat.y );
msg.WriteDeltaFloat( quat.z, localQuat.z );
}
}
/*
================
idPhysics_StaticMulti::ReadFromSnapshot
================
*/
void idPhysics_StaticMulti::ReadFromSnapshot( const idBitMsg& msg )
{
2012-11-26 18:58:24 +00:00
int i, num;
idCQuat quat, localQuat;
2012-11-26 18:58:24 +00:00
num = msg.ReadByte();
assert( num == current.Num() );
2012-11-26 18:58:24 +00:00
previous = next;
2012-11-26 18:58:24 +00:00
next.SetNum( num );
for( i = 0; i < current.Num(); i++ )
{
2012-11-26 18:58:24 +00:00
next[i] = ReadStaticInterpolatePStateFromSnapshot( msg );
}
}