1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #include "sys/platform.h"
30 #include "idlib/math/Quat.h"
31 
32 #include "gamesys/SysCvar.h"
33 #include "physics/Force.h"
34 #include "Entity.h"
35 
36 #include "physics/Physics_Static.h"
37 
CLASS_DECLARATION(idPhysics,idPhysics_Static)38 CLASS_DECLARATION( idPhysics, idPhysics_Static )
39 END_CLASS
40 
41 /*
42 ================
43 idPhysics_Static::idPhysics_Static
44 ================
45 */
46 idPhysics_Static::idPhysics_Static( void ) {
47 	self = NULL;
48 	clipModel = NULL;
49 	current.origin.Zero();
50 	current.axis.Identity();
51 	current.localOrigin.Zero();
52 	current.localAxis.Identity();
53 	hasMaster = false;
54 	isOrientated = false;
55 }
56 
57 /*
58 ================
59 idPhysics_Static::~idPhysics_Static
60 ================
61 */
~idPhysics_Static(void)62 idPhysics_Static::~idPhysics_Static( void ) {
63 	if ( self && self->GetPhysics() == this ) {
64 		self->SetPhysics( NULL );
65 	}
66 	idForce::DeletePhysics( this );
67 	if ( clipModel ) {
68 		delete clipModel;
69 	}
70 }
71 
72 /*
73 ================
74 idPhysics_Static::Save
75 ================
76 */
Save(idSaveGame * savefile) const77 void idPhysics_Static::Save( idSaveGame *savefile ) const {
78 	savefile->WriteObject( self );
79 
80 	savefile->WriteVec3( current.origin );
81 	savefile->WriteMat3( current.axis );
82 	savefile->WriteVec3( current.localOrigin );
83 	savefile->WriteMat3( current.localAxis );
84 	savefile->WriteClipModel( clipModel );
85 
86 	savefile->WriteBool( hasMaster );
87 	savefile->WriteBool( isOrientated );
88 }
89 
90 /*
91 ================
92 idPhysics_Static::Restore
93 ================
94 */
Restore(idRestoreGame * savefile)95 void idPhysics_Static::Restore( idRestoreGame *savefile ) {
96 	savefile->ReadObject( reinterpret_cast<idClass *&>( self ) );
97 
98 	savefile->ReadVec3( current.origin );
99 	savefile->ReadMat3( current.axis );
100 	savefile->ReadVec3( current.localOrigin );
101 	savefile->ReadMat3( current.localAxis );
102 	savefile->ReadClipModel( clipModel );
103 
104 	savefile->ReadBool( hasMaster );
105 	savefile->ReadBool( isOrientated );
106 }
107 
108 /*
109 ================
110 idPhysics_Static::SetSelf
111 ================
112 */
SetSelf(idEntity * e)113 void idPhysics_Static::SetSelf( idEntity *e ) {
114 	assert( e );
115 	self = e;
116 }
117 
118 /*
119 ================
120 idPhysics_Static::SetClipModel
121 ================
122 */
SetClipModel(idClipModel * model,float density,int id,bool freeOld)123 void idPhysics_Static::SetClipModel( idClipModel *model, float density, int id, bool freeOld ) {
124 	assert( self );
125 
126 	if ( clipModel && clipModel != model && freeOld ) {
127 		delete clipModel;
128 	}
129 	clipModel = model;
130 	if ( clipModel ) {
131 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
132 	}
133 }
134 
135 /*
136 ================
137 idPhysics_Static::GetClipModel
138 ================
139 */
GetClipModel(int id) const140 idClipModel *idPhysics_Static::GetClipModel( int id ) const {
141 	if ( clipModel ) {
142 		return clipModel;
143 	}
144 	return gameLocal.clip.DefaultClipModel();
145 }
146 
147 /*
148 ================
149 idPhysics_Static::GetNumClipModels
150 ================
151 */
GetNumClipModels(void) const152 int idPhysics_Static::GetNumClipModels( void ) const {
153 	return ( clipModel != NULL );
154 }
155 
156 /*
157 ================
158 idPhysics_Static::SetMass
159 ================
160 */
SetMass(float mass,int id)161 void idPhysics_Static::SetMass( float mass, int id ) {
162 }
163 
164 /*
165 ================
166 idPhysics_Static::GetMass
167 ================
168 */
GetMass(int id) const169 float idPhysics_Static::GetMass( int id ) const {
170 	return 0.0f;
171 }
172 
173 /*
174 ================
175 idPhysics_Static::SetContents
176 ================
177 */
SetContents(int contents,int id)178 void idPhysics_Static::SetContents( int contents, int id ) {
179 	if ( clipModel ) {
180 		clipModel->SetContents( contents );
181 	}
182 }
183 
184 /*
185 ================
186 idPhysics_Static::GetContents
187 ================
188 */
GetContents(int id) const189 int idPhysics_Static::GetContents( int id ) const {
190 	if ( clipModel ) {
191 		return clipModel->GetContents();
192 	}
193 	return 0;
194 }
195 
196 /*
197 ================
198 idPhysics_Static::SetClipMask
199 ================
200 */
SetClipMask(int mask,int id)201 void idPhysics_Static::SetClipMask( int mask, int id ) {
202 }
203 
204 /*
205 ================
206 idPhysics_Static::GetClipMask
207 ================
208 */
GetClipMask(int id) const209 int idPhysics_Static::GetClipMask( int id ) const {
210 	return 0;
211 }
212 
213 /*
214 ================
215 idPhysics_Static::GetBounds
216 ================
217 */
GetBounds(int id) const218 const idBounds &idPhysics_Static::GetBounds( int id ) const {
219 	if ( clipModel ) {
220 		return clipModel->GetBounds();
221 	}
222 	return bounds_zero;
223 }
224 
225 /*
226 ================
227 idPhysics_Static::GetAbsBounds
228 ================
229 */
GetAbsBounds(int id) const230 const idBounds &idPhysics_Static::GetAbsBounds( int id ) const {
231 	static idBounds absBounds;
232 
233 	if ( clipModel ) {
234 		return clipModel->GetAbsBounds();
235 	}
236 	absBounds[0] = absBounds[1] = current.origin;
237 	return absBounds;
238 }
239 
240 /*
241 ================
242 idPhysics_Static::Evaluate
243 ================
244 */
Evaluate(int timeStepMSec,int endTimeMSec)245 bool idPhysics_Static::Evaluate( int timeStepMSec, int endTimeMSec ) {
246 	idVec3 masterOrigin, oldOrigin;
247 	idMat3 masterAxis, oldAxis;
248 
249 
250 	if ( hasMaster ) {
251 		oldOrigin = current.origin;
252 		oldAxis = current.axis;
253 
254 		self->GetMasterPosition( masterOrigin, masterAxis );
255 		current.origin = masterOrigin + current.localOrigin * masterAxis;
256 		if ( isOrientated ) {
257 			current.axis = current.localAxis * masterAxis;
258 		} else {
259 			current.axis = current.localAxis;
260 		}
261 		if ( clipModel ) {
262 			clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
263 		}
264 
265 		return ( current.origin != oldOrigin || current.axis != oldAxis );
266 	}
267 	return false;
268 }
269 
270 /*
271 ================
272 idPhysics_Static::UpdateTime
273 ================
274 */
UpdateTime(int endTimeMSec)275 void idPhysics_Static::UpdateTime( int endTimeMSec ) {
276 }
277 
278 /*
279 ================
280 idPhysics_Static::GetTime
281 ================
282 */
GetTime(void) const283 int idPhysics_Static::GetTime( void ) const {
284 	return 0;
285 }
286 
287 /*
288 ================
289 idPhysics_Static::GetImpactInfo
290 ================
291 */
GetImpactInfo(const int id,const idVec3 & point,impactInfo_t * info) const292 void idPhysics_Static::GetImpactInfo( const int id, const idVec3 &point, impactInfo_t *info ) const {
293 	memset( info, 0, sizeof( *info ) );
294 }
295 
296 /*
297 ================
298 idPhysics_Static::ApplyImpulse
299 ================
300 */
ApplyImpulse(const int id,const idVec3 & point,const idVec3 & impulse)301 void idPhysics_Static::ApplyImpulse( const int id, const idVec3 &point, const idVec3 &impulse ) {
302 }
303 
304 /*
305 ================
306 idPhysics_Static::AddForce
307 ================
308 */
AddForce(const int id,const idVec3 & point,const idVec3 & force)309 void idPhysics_Static::AddForce( const int id, const idVec3 &point, const idVec3 &force ) {
310 }
311 
312 /*
313 ================
314 idPhysics_Static::Activate
315 ================
316 */
Activate(void)317 void idPhysics_Static::Activate( void ) {
318 }
319 
320 /*
321 ================
322 idPhysics_Static::PutToRest
323 ================
324 */
PutToRest(void)325 void idPhysics_Static::PutToRest( void ) {
326 }
327 
328 /*
329 ================
330 idPhysics_Static::IsAtRest
331 ================
332 */
IsAtRest(void) const333 bool idPhysics_Static::IsAtRest( void ) const {
334 	return true;
335 }
336 
337 /*
338 ================
339 idPhysics_Static::GetRestStartTime
340 ================
341 */
GetRestStartTime(void) const342 int idPhysics_Static::GetRestStartTime( void ) const {
343 	return 0;
344 }
345 
346 /*
347 ================
348 idPhysics_Static::IsPushable
349 ================
350 */
IsPushable(void) const351 bool idPhysics_Static::IsPushable( void ) const {
352 	return false;
353 }
354 
355 /*
356 ================
357 idPhysics_Static::SaveState
358 ================
359 */
SaveState(void)360 void idPhysics_Static::SaveState( void ) {
361 }
362 
363 /*
364 ================
365 idPhysics_Static::RestoreState
366 ================
367 */
RestoreState(void)368 void idPhysics_Static::RestoreState( void ) {
369 }
370 
371 /*
372 ================
373 idPhysics_Static::SetOrigin
374 ================
375 */
SetOrigin(const idVec3 & newOrigin,int id)376 void idPhysics_Static::SetOrigin( const idVec3 &newOrigin, int id ) {
377 	idVec3 masterOrigin;
378 	idMat3 masterAxis;
379 
380 	current.localOrigin = newOrigin;
381 
382 	if ( hasMaster ) {
383 		self->GetMasterPosition( masterOrigin, masterAxis );
384 		current.origin = masterOrigin + newOrigin * masterAxis;
385 	} else {
386 		current.origin = newOrigin;
387 	}
388 
389 	if ( clipModel ) {
390 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
391 	}
392 }
393 
394 /*
395 ================
396 idPhysics_Static::SetAxis
397 ================
398 */
SetAxis(const idMat3 & newAxis,int id)399 void idPhysics_Static::SetAxis( const idMat3 &newAxis, int id ) {
400 	idVec3 masterOrigin;
401 	idMat3 masterAxis;
402 
403 	current.localAxis = newAxis;
404 
405 	if ( hasMaster && isOrientated ) {
406 		self->GetMasterPosition( masterOrigin, masterAxis );
407 		current.axis = newAxis * masterAxis;
408 	} else {
409 		current.axis = newAxis;
410 	}
411 
412 	if ( clipModel ) {
413 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
414 	}
415 }
416 
417 /*
418 ================
419 idPhysics_Static::Translate
420 ================
421 */
Translate(const idVec3 & translation,int id)422 void idPhysics_Static::Translate( const idVec3 &translation, int id ) {
423 	current.localOrigin += translation;
424 	current.origin += translation;
425 
426 	if ( clipModel ) {
427 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
428 	}
429 }
430 
431 /*
432 ================
433 idPhysics_Static::Rotate
434 ================
435 */
Rotate(const idRotation & rotation,int id)436 void idPhysics_Static::Rotate( const idRotation &rotation, int id ) {
437 	idVec3 masterOrigin;
438 	idMat3 masterAxis;
439 
440 	current.origin *= rotation;
441 	current.axis *= rotation.ToMat3();
442 
443 	if ( hasMaster ) {
444 		self->GetMasterPosition( masterOrigin, masterAxis );
445 		current.localAxis *= rotation.ToMat3();
446 		current.localOrigin = ( current.origin - masterOrigin ) * masterAxis.Transpose();
447 	} else {
448 		current.localAxis = current.axis;
449 		current.localOrigin = current.origin;
450 	}
451 
452 	if ( clipModel ) {
453 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
454 	}
455 }
456 
457 /*
458 ================
459 idPhysics_Static::GetOrigin
460 ================
461 */
GetOrigin(int id) const462 const idVec3 &idPhysics_Static::GetOrigin( int id ) const {
463 	return current.origin;
464 }
465 
466 /*
467 ================
468 idPhysics_Static::GetAxis
469 ================
470 */
GetAxis(int id) const471 const idMat3 &idPhysics_Static::GetAxis( int id ) const {
472 	return current.axis;
473 }
474 
475 /*
476 ================
477 idPhysics_Static::SetLinearVelocity
478 ================
479 */
SetLinearVelocity(const idVec3 & newLinearVelocity,int id)480 void idPhysics_Static::SetLinearVelocity( const idVec3 &newLinearVelocity, int id ) {
481 }
482 
483 /*
484 ================
485 idPhysics_Static::SetAngularVelocity
486 ================
487 */
SetAngularVelocity(const idVec3 & newAngularVelocity,int id)488 void idPhysics_Static::SetAngularVelocity( const idVec3 &newAngularVelocity, int id ) {
489 }
490 
491 /*
492 ================
493 idPhysics_Static::GetLinearVelocity
494 ================
495 */
GetLinearVelocity(int id) const496 const idVec3 &idPhysics_Static::GetLinearVelocity( int id ) const {
497 	return vec3_origin;
498 }
499 
500 /*
501 ================
502 idPhysics_Static::GetAngularVelocity
503 ================
504 */
GetAngularVelocity(int id) const505 const idVec3 &idPhysics_Static::GetAngularVelocity( int id ) const {
506 	return vec3_origin;
507 }
508 
509 /*
510 ================
511 idPhysics_Static::SetGravity
512 ================
513 */
SetGravity(const idVec3 & newGravity)514 void idPhysics_Static::SetGravity( const idVec3 &newGravity ) {
515 }
516 
517 /*
518 ================
519 idPhysics_Static::GetGravity
520 ================
521 */
GetGravity(void) const522 const idVec3 &idPhysics_Static::GetGravity( void ) const {
523 	static idVec3 gravity( 0, 0, -g_gravity.GetFloat() );
524 	return gravity;
525 }
526 
527 /*
528 ================
529 idPhysics_Static::GetGravityNormal
530 ================
531 */
GetGravityNormal(void) const532 const idVec3 &idPhysics_Static::GetGravityNormal( void ) const {
533 	static idVec3 gravity( 0, 0, -1 );
534 	return gravity;
535 }
536 
537 /*
538 ================
539 idPhysics_Static::ClipTranslation
540 ================
541 */
ClipTranslation(trace_t & results,const idVec3 & translation,const idClipModel * model) const542 void idPhysics_Static::ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const {
543 	if ( model ) {
544 		gameLocal.clip.TranslationModel( results, current.origin, current.origin + translation,
545 			clipModel, current.axis, MASK_SOLID, model->Handle(), model->GetOrigin(), model->GetAxis() );
546 	} else {
547 		gameLocal.clip.Translation( results, current.origin, current.origin + translation,
548 			clipModel, current.axis, MASK_SOLID, self );
549 	}
550 }
551 
552 /*
553 ================
554 idPhysics_Static::ClipRotation
555 ================
556 */
ClipRotation(trace_t & results,const idRotation & rotation,const idClipModel * model) const557 void idPhysics_Static::ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const {
558 	if ( model ) {
559 		gameLocal.clip.RotationModel( results, current.origin, rotation,
560 			clipModel, current.axis, MASK_SOLID, model->Handle(), model->GetOrigin(), model->GetAxis() );
561 	} else {
562 		gameLocal.clip.Rotation( results, current.origin, rotation, clipModel, current.axis, MASK_SOLID, self );
563 	}
564 }
565 
566 /*
567 ================
568 idPhysics_Static::ClipContents
569 ================
570 */
ClipContents(const idClipModel * model) const571 int idPhysics_Static::ClipContents( const idClipModel *model ) const {
572 	if ( clipModel ) {
573 		if ( model ) {
574 			return gameLocal.clip.ContentsModel( clipModel->GetOrigin(), clipModel, clipModel->GetAxis(), -1,
575 				model->Handle(), model->GetOrigin(), model->GetAxis() );
576 		} else {
577 			return gameLocal.clip.Contents( clipModel->GetOrigin(), clipModel, clipModel->GetAxis(), -1, NULL );
578 		}
579 	}
580 	return 0;
581 }
582 
583 /*
584 ================
585 idPhysics_Static::DisableClip
586 ================
587 */
DisableClip(void)588 void idPhysics_Static::DisableClip( void ) {
589 	if ( clipModel ) {
590 		clipModel->Disable();
591 	}
592 }
593 
594 /*
595 ================
596 idPhysics_Static::EnableClip
597 ================
598 */
EnableClip(void)599 void idPhysics_Static::EnableClip( void ) {
600 	if ( clipModel ) {
601 		clipModel->Enable();
602 	}
603 }
604 
605 /*
606 ================
607 idPhysics_Static::UnlinkClip
608 ================
609 */
UnlinkClip(void)610 void idPhysics_Static::UnlinkClip( void ) {
611 	if ( clipModel ) {
612 		clipModel->Unlink();
613 	}
614 }
615 
616 /*
617 ================
618 idPhysics_Static::LinkClip
619 ================
620 */
LinkClip(void)621 void idPhysics_Static::LinkClip( void ) {
622 	if ( clipModel ) {
623 		clipModel->Link( gameLocal.clip, self, 0, current.origin, current.axis );
624 	}
625 }
626 
627 /*
628 ================
629 idPhysics_Static::EvaluateContacts
630 ================
631 */
EvaluateContacts(void)632 bool idPhysics_Static::EvaluateContacts( void ) {
633 	return false;
634 }
635 
636 /*
637 ================
638 idPhysics_Static::GetNumContacts
639 ================
640 */
GetNumContacts(void) const641 int idPhysics_Static::GetNumContacts( void ) const {
642 	return 0;
643 }
644 
645 /*
646 ================
647 idPhysics_Static::GetContact
648 ================
649 */
GetContact(int num) const650 const contactInfo_t &idPhysics_Static::GetContact( int num ) const {
651 	static contactInfo_t info;
652 	memset( &info, 0, sizeof( info ) );
653 	return info;
654 }
655 
656 /*
657 ================
658 idPhysics_Static::ClearContacts
659 ================
660 */
ClearContacts(void)661 void idPhysics_Static::ClearContacts( void ) {
662 }
663 
664 /*
665 ================
666 idPhysics_Static::AddContactEntity
667 ================
668 */
AddContactEntity(idEntity * e)669 void idPhysics_Static::AddContactEntity( idEntity *e ) {
670 }
671 
672 /*
673 ================
674 idPhysics_Static::RemoveContactEntity
675 ================
676 */
RemoveContactEntity(idEntity * e)677 void idPhysics_Static::RemoveContactEntity( idEntity *e ) {
678 }
679 
680 /*
681 ================
682 idPhysics_Static::HasGroundContacts
683 ================
684 */
HasGroundContacts(void) const685 bool idPhysics_Static::HasGroundContacts( void ) const {
686 	return false;
687 }
688 
689 /*
690 ================
691 idPhysics_Static::IsGroundEntity
692 ================
693 */
IsGroundEntity(int entityNum) const694 bool idPhysics_Static::IsGroundEntity( int entityNum ) const {
695 	return false;
696 }
697 
698 /*
699 ================
700 idPhysics_Static::IsGroundClipModel
701 ================
702 */
IsGroundClipModel(int entityNum,int id) const703 bool idPhysics_Static::IsGroundClipModel( int entityNum, int id ) const {
704 	return false;
705 }
706 
707 /*
708 ================
709 idPhysics_Static::SetPushed
710 ================
711 */
SetPushed(int deltaTime)712 void idPhysics_Static::SetPushed( int deltaTime ) {
713 }
714 
715 /*
716 ================
717 idPhysics_Static::GetPushedLinearVelocity
718 ================
719 */
GetPushedLinearVelocity(const int id) const720 const idVec3 &idPhysics_Static::GetPushedLinearVelocity( const int id ) const {
721 	return vec3_origin;
722 }
723 
724 /*
725 ================
726 idPhysics_Static::GetPushedAngularVelocity
727 ================
728 */
GetPushedAngularVelocity(const int id) const729 const idVec3 &idPhysics_Static::GetPushedAngularVelocity( const int id ) const {
730 	return vec3_origin;
731 }
732 
733 /*
734 ================
735 idPhysics_Static::SetMaster
736 ================
737 */
SetMaster(idEntity * master,const bool orientated)738 void idPhysics_Static::SetMaster( idEntity *master, const bool orientated ) {
739 	idVec3 masterOrigin;
740 	idMat3 masterAxis;
741 
742 	if ( master ) {
743 		if ( !hasMaster ) {
744 			// transform from world space to master space
745 			self->GetMasterPosition( masterOrigin, masterAxis );
746 			current.localOrigin = ( current.origin - masterOrigin ) * masterAxis.Transpose();
747 			if ( orientated ) {
748 				current.localAxis = current.axis * masterAxis.Transpose();
749 			} else {
750 				current.localAxis = current.axis;
751 			}
752 			hasMaster = true;
753 			isOrientated = orientated;
754 		}
755 	} else {
756 		if ( hasMaster ) {
757 			hasMaster = false;
758 		}
759 	}
760 }
761 
762 /*
763 ================
764 idPhysics_Static::GetBlockingInfo
765 ================
766 */
GetBlockingInfo(void) const767 const trace_t *idPhysics_Static::GetBlockingInfo( void ) const {
768 	return NULL;
769 }
770 
771 /*
772 ================
773 idPhysics_Static::GetBlockingEntity
774 ================
775 */
GetBlockingEntity(void) const776 idEntity *idPhysics_Static::GetBlockingEntity( void ) const {
777 	return NULL;
778 }
779 
780 /*
781 ================
782 idPhysics_Static::GetLinearEndTime
783 ================
784 */
GetLinearEndTime(void) const785 int idPhysics_Static::GetLinearEndTime( void ) const {
786 	return 0;
787 }
788 
789 /*
790 ================
791 idPhysics_Static::GetAngularEndTime
792 ================
793 */
GetAngularEndTime(void) const794 int idPhysics_Static::GetAngularEndTime( void ) const {
795 	return 0;
796 }
797 
798 /*
799 ================
800 idPhysics_Static::WriteToSnapshot
801 ================
802 */
WriteToSnapshot(idBitMsgDelta & msg) const803 void idPhysics_Static::WriteToSnapshot( idBitMsgDelta &msg ) const {
804 	idCQuat quat, localQuat;
805 
806 	quat = current.axis.ToCQuat();
807 	localQuat = current.localAxis.ToCQuat();
808 
809 	msg.WriteFloat( current.origin[0] );
810 	msg.WriteFloat( current.origin[1] );
811 	msg.WriteFloat( current.origin[2] );
812 	msg.WriteFloat( quat.x );
813 	msg.WriteFloat( quat.y );
814 	msg.WriteFloat( quat.z );
815 	msg.WriteDeltaFloat( current.origin[0], current.localOrigin[0] );
816 	msg.WriteDeltaFloat( current.origin[1], current.localOrigin[1] );
817 	msg.WriteDeltaFloat( current.origin[2], current.localOrigin[2] );
818 	msg.WriteDeltaFloat( quat.x, localQuat.x );
819 	msg.WriteDeltaFloat( quat.y, localQuat.y );
820 	msg.WriteDeltaFloat( quat.z, localQuat.z );
821 }
822 
823 /*
824 ================
825 idPhysics_Base::ReadFromSnapshot
826 ================
827 */
ReadFromSnapshot(const idBitMsgDelta & msg)828 void idPhysics_Static::ReadFromSnapshot( const idBitMsgDelta &msg ) {
829 	idCQuat quat, localQuat;
830 
831 	current.origin[0] = msg.ReadFloat();
832 	current.origin[1] = msg.ReadFloat();
833 	current.origin[2] = msg.ReadFloat();
834 	quat.x = msg.ReadFloat();
835 	quat.y = msg.ReadFloat();
836 	quat.z = msg.ReadFloat();
837 	current.localOrigin[0] = msg.ReadDeltaFloat( current.origin[0] );
838 	current.localOrigin[1] = msg.ReadDeltaFloat( current.origin[1] );
839 	current.localOrigin[2] = msg.ReadDeltaFloat( current.origin[2] );
840 	localQuat.x = msg.ReadDeltaFloat( quat.x );
841 	localQuat.y = msg.ReadDeltaFloat( quat.y );
842 	localQuat.z = msg.ReadDeltaFloat( quat.z );
843 
844 	current.axis = quat.ToMat3();
845 	current.localAxis = localQuat.ToMat3();
846 }
847