doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Physics_StaticMulti.cpp
Go to the documentation of this file.
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 "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../Game_local.h"
33 
36 
38 
39 
40 /*
41 ================
42 idPhysics_StaticMulti::idPhysics_StaticMulti
43 ================
44 */
46  self = NULL;
47  hasMaster = false;
48  isOrientated = false;
49 
50  defaultState.origin.Zero();
51  defaultState.axis.Identity();
52  defaultState.localOrigin.Zero();
53  defaultState.localAxis.Identity();
54 
55  current.SetNum( 1 );
56  current[0] = defaultState;
57  clipModels.SetNum( 1 );
58  clipModels[0] = NULL;
59 }
60 
61 /*
62 ================
63 idPhysics_StaticMulti::~idPhysics_StaticMulti
64 ================
65 */
67  if ( self && self->GetPhysics() == this ) {
68  self->SetPhysics( NULL );
69  }
70  idForce::DeletePhysics( this );
71  for ( int i = 0; i < clipModels.Num(); i++ ) {
72  delete clipModels[i];
73  }
74 }
75 
76 /*
77 ================
78 idPhysics_StaticMulti::Save
79 ================
80 */
81 void idPhysics_StaticMulti::Save( idSaveGame *savefile ) const {
82  int i;
83 
84  savefile->WriteObject( self );
85 
86  savefile->WriteInt(current.Num());
87  for ( i = 0; i < current.Num(); i++ ) {
88  savefile->WriteVec3( current[i].origin );
89  savefile->WriteMat3( current[i].axis );
90  savefile->WriteVec3( current[i].localOrigin );
91  savefile->WriteMat3( current[i].localAxis );
92  }
93 
94  savefile->WriteInt( clipModels.Num() );
95  for ( i = 0; i < clipModels.Num(); i++ ) {
96  savefile->WriteClipModel( clipModels[i] );
97  }
98 
99  savefile->WriteBool(hasMaster);
100  savefile->WriteBool(isOrientated);
101 }
102 
103 /*
104 ================
105 idPhysics_StaticMulti::Restore
106 ================
107 */
109  int i, num;
110 
111  savefile->ReadObject( reinterpret_cast<idClass *&>( self ) );
112 
113  savefile->ReadInt(num);
114  current.AssureSize( num );
115  for ( i = 0; i < num; i++ ) {
116  savefile->ReadVec3( current[i].origin );
117  savefile->ReadMat3( current[i].axis );
118  savefile->ReadVec3( current[i].localOrigin );
119  savefile->ReadMat3( current[i].localAxis );
120  }
121 
122  savefile->ReadInt(num);
123  clipModels.SetNum( num );
124  for ( i = 0; i < num; i++ ) {
125  savefile->ReadClipModel( clipModels[i] );
126  }
127 
128  savefile->ReadBool(hasMaster);
129  savefile->ReadBool(isOrientated);
130 }
131 
132 /*
133 ================
134 idPhysics_StaticMulti::SetSelf
135 ================
136 */
138  assert( e );
139  self = e;
140 }
141 
142 /*
143 ================
144 idPhysics_StaticMulti::RemoveIndex
145 ================
146 */
147 void idPhysics_StaticMulti::RemoveIndex( int id, bool freeClipModel ) {
148  if ( id < 0 || id >= clipModels.Num() ) {
149  return;
150  }
151  if ( clipModels[id] && freeClipModel ) {
152  delete clipModels[id];
153  clipModels[id] = NULL;
154  }
155  clipModels.RemoveIndex( id );
156  current.RemoveIndex( id );
157 }
158 
159 /*
160 ================
161 idPhysics_StaticMulti::SetClipModel
162 ================
163 */
164 void idPhysics_StaticMulti::SetClipModel( idClipModel *model, float density, int id, bool freeOld ) {
165  int i;
166 
167  assert( self );
168 
169  if ( id >= clipModels.Num() ) {
170  current.AssureSize( id+1, defaultState );
171  clipModels.AssureSize( id+1, NULL );
172  }
173 
174  if ( clipModels[id] && clipModels[id] != model && freeOld ) {
175  delete clipModels[id];
176  }
177  clipModels[id] = model;
178  if ( clipModels[id] ) {
179  clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
180  }
181 
182  for ( i = clipModels.Num() - 1; i >= 1; i-- ) {
183  if ( clipModels[i] ) {
184  break;
185  }
186  }
187  current.SetNum( i+1, false );
188  clipModels.SetNum( i+1, false );
189 }
190 
191 /*
192 ================
193 idPhysics_StaticMulti::GetClipModel
194 ================
195 */
197  if ( id >= 0 && id < clipModels.Num() && clipModels[id] ) {
198  return clipModels[id];
199  }
201 }
202 
203 /*
204 ================
205 idPhysics_StaticMulti::GetNumClipModels
206 ================
207 */
209  return clipModels.Num();
210 }
211 
212 /*
213 ================
214 idPhysics_StaticMulti::SetMass
215 ================
216 */
217 void idPhysics_StaticMulti::SetMass( float mass, int id ) {
218 }
219 
220 /*
221 ================
222 idPhysics_StaticMulti::GetMass
223 ================
224 */
225 float idPhysics_StaticMulti::GetMass( int id ) const {
226  return 0.0f;
227 }
228 
229 /*
230 ================
231 idPhysics_StaticMulti::SetContents
232 ================
233 */
234 void idPhysics_StaticMulti::SetContents( int contents, int id ) {
235  int i;
236 
237  if ( id >= 0 && id < clipModels.Num() ) {
238  if ( clipModels[id] ) {
239  clipModels[id]->SetContents( contents );
240  }
241  } else if ( id == -1 ) {
242  for ( i = 0; i < clipModels.Num(); i++ ) {
243  if ( clipModels[i] ) {
244  clipModels[i]->SetContents( contents );
245  }
246  }
247  }
248 }
249 
250 /*
251 ================
252 idPhysics_StaticMulti::GetContents
253 ================
254 */
256  int i, contents = 0;
257 
258  if ( id >= 0 && id < clipModels.Num() ) {
259  if ( clipModels[id] ) {
260  contents = clipModels[id]->GetContents();
261  }
262  } else if ( id == -1 ) {
263  for ( i = 0; i < clipModels.Num(); i++ ) {
264  if ( clipModels[i] ) {
265  contents |= clipModels[i]->GetContents();
266  }
267  }
268  }
269  return contents;
270 }
271 
272 /*
273 ================
274 idPhysics_StaticMulti::SetClipMask
275 ================
276 */
278 }
279 
280 /*
281 ================
282 idPhysics_StaticMulti::GetClipMask
283 ================
284 */
286  return 0;
287 }
288 
289 /*
290 ================
291 idPhysics_StaticMulti::GetBounds
292 ================
293 */
295  int i;
296  static idBounds bounds;
297 
298  if ( id >= 0 && id < clipModels.Num() ) {
299  if ( clipModels[id] ) {
300  return clipModels[id]->GetBounds();
301  }
302  }
303  if ( id == -1 ) {
304  bounds.Clear();
305  for ( i = 0; i < clipModels.Num(); i++ ) {
306  if ( clipModels[i] ) {
307  bounds.AddBounds( clipModels[i]->GetAbsBounds() );
308  }
309  }
310  for ( i = 0; i < clipModels.Num(); i++ ) {
311  if ( clipModels[i] ) {
312  bounds[0] -= clipModels[i]->GetOrigin();
313  bounds[1] -= clipModels[i]->GetOrigin();
314  break;
315  }
316  }
317  return bounds;
318  }
319  return bounds_zero;
320 }
321 
322 /*
323 ================
324 idPhysics_StaticMulti::GetAbsBounds
325 ================
326 */
328  int i;
329  static idBounds absBounds;
330 
331  if ( id >= 0 && id < clipModels.Num() ) {
332  if ( clipModels[id] ) {
333  return clipModels[id]->GetAbsBounds();
334  }
335  }
336  if ( id == -1 ) {
337  absBounds.Clear();
338  for ( i = 0; i < clipModels.Num(); i++ ) {
339  if ( clipModels[i] ) {
340  absBounds.AddBounds( clipModels[i]->GetAbsBounds() );
341  }
342  }
343  return absBounds;
344  }
345  return bounds_zero;
346 }
347 
348 /*
349 ================
350 idPhysics_StaticMulti::Evaluate
351 ================
352 */
353 bool idPhysics_StaticMulti::Evaluate( int timeStepMSec, int endTimeMSec ) {
354  int i;
355  idVec3 masterOrigin;
356  idMat3 masterAxis;
357 
358  if ( hasMaster ) {
359  self->GetMasterPosition( masterOrigin, masterAxis );
360  for ( i = 0; i < clipModels.Num(); i++ ) {
361  current[i].origin = masterOrigin + current[i].localOrigin * masterAxis;
362  if ( isOrientated ) {
363  current[i].axis = current[i].localAxis * masterAxis;
364  } else {
365  current[i].axis = current[i].localAxis;
366  }
367  if ( clipModels[i] ) {
368  clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
369  }
370  }
371 
372  // FIXME: return false if master did not move
373  return true;
374  }
375  return false;
376 }
377 
378 /*
379 ================
380 idPhysics_StaticMulti::UpdateTime
381 ================
382 */
383 void idPhysics_StaticMulti::UpdateTime( int endTimeMSec ) {
384 }
385 
386 /*
387 ================
388 idPhysics_StaticMulti::GetTime
389 ================
390 */
392  return 0;
393 }
394 
395 /*
396 ================
397 idPhysics_StaticMulti::GetImpactInfo
398 ================
399 */
400 void idPhysics_StaticMulti::GetImpactInfo( const int id, const idVec3 &point, impactInfo_t *info ) const {
401  memset( info, 0, sizeof( *info ) );
402 }
403 
404 /*
405 ================
406 idPhysics_StaticMulti::ApplyImpulse
407 ================
408 */
409 void idPhysics_StaticMulti::ApplyImpulse( const int id, const idVec3 &point, const idVec3 &impulse ) {
410 }
411 
412 /*
413 ================
414 idPhysics_StaticMulti::AddForce
415 ================
416 */
417 void idPhysics_StaticMulti::AddForce( const int id, const idVec3 &point, const idVec3 &force ) {
418 }
419 
420 /*
421 ================
422 idPhysics_StaticMulti::Activate
423 ================
424 */
426 }
427 
428 /*
429 ================
430 idPhysics_StaticMulti::PutToRest
431 ================
432 */
434 }
435 
436 /*
437 ================
438 idPhysics_StaticMulti::IsAtRest
439 ================
440 */
442  return true;
443 }
444 
445 /*
446 ================
447 idPhysics_StaticMulti::GetRestStartTime
448 ================
449 */
451  return 0;
452 }
453 
454 /*
455 ================
456 idPhysics_StaticMulti::IsPushable
457 ================
458 */
460  return false;
461 }
462 
463 /*
464 ================
465 idPhysics_StaticMulti::SaveState
466 ================
467 */
469 }
470 
471 /*
472 ================
473 idPhysics_StaticMulti::RestoreState
474 ================
475 */
477 }
478 
479 /*
480 ================
481 idPhysics_StaticMulti::SetOrigin
482 ================
483 */
484 void idPhysics_StaticMulti::SetOrigin( const idVec3 &newOrigin, int id ) {
485  idVec3 masterOrigin;
486  idMat3 masterAxis;
487 
488  if ( id >= 0 && id < clipModels.Num() ) {
489  current[id].localOrigin = newOrigin;
490  if ( hasMaster ) {
491  self->GetMasterPosition( masterOrigin, masterAxis );
492  current[id].origin = masterOrigin + newOrigin * masterAxis;
493  } else {
494  current[id].origin = newOrigin;
495  }
496  if ( clipModels[id] ) {
497  clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
498  }
499  } else if ( id == -1 ) {
500  if ( hasMaster ) {
501  self->GetMasterPosition( masterOrigin, masterAxis );
502  Translate( masterOrigin + masterAxis * newOrigin - current[0].origin );
503  } else {
504  Translate( newOrigin - current[0].origin );
505  }
506  }
507 }
508 
509 /*
510 ================
511 idPhysics_StaticMulti::SetAxis
512 ================
513 */
514 void idPhysics_StaticMulti::SetAxis( const idMat3 &newAxis, int id ) {
515  idVec3 masterOrigin;
516  idMat3 masterAxis;
517 
518  if ( id >= 0 && id < clipModels.Num() ) {
519  current[id].localAxis = newAxis;
520  if ( hasMaster && isOrientated ) {
521  self->GetMasterPosition( masterOrigin, masterAxis );
522  current[id].axis = newAxis * masterAxis;
523  } else {
524  current[id].axis = newAxis;
525  }
526  if ( clipModels[id] ) {
527  clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
528  }
529  } else if ( id == -1 ) {
530  idMat3 axis;
531  idRotation rotation;
532 
533  if ( hasMaster ) {
534  self->GetMasterPosition( masterOrigin, masterAxis );
535  axis = current[0].axis.Transpose() * ( newAxis * masterAxis );
536  } else {
537  axis = current[0].axis.Transpose() * newAxis;
538  }
539  rotation = axis.ToRotation();
540  rotation.SetOrigin( current[0].origin );
541 
542  Rotate( rotation );
543  }
544 }
545 
546 /*
547 ================
548 idPhysics_StaticMulti::Translate
549 ================
550 */
551 void idPhysics_StaticMulti::Translate( const idVec3 &translation, int id ) {
552  int i;
553 
554  if ( id >= 0 && id < clipModels.Num() ) {
555  current[id].localOrigin += translation;
556  current[id].origin += translation;
557 
558  if ( clipModels[id] ) {
559  clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
560  }
561  } else if ( id == -1 ) {
562  for ( i = 0; i < clipModels.Num(); i++ ) {
563  current[i].localOrigin += translation;
564  current[i].origin += translation;
565 
566  if ( clipModels[i] ) {
567  clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
568  }
569  }
570  }
571 }
572 
573 /*
574 ================
575 idPhysics_StaticMulti::Rotate
576 ================
577 */
578 void idPhysics_StaticMulti::Rotate( const idRotation &rotation, int id ) {
579  int i;
580  idVec3 masterOrigin;
581  idMat3 masterAxis;
582 
583  if ( id >= 0 && id < clipModels.Num() ) {
584  current[id].origin *= rotation;
585  current[id].axis *= rotation.ToMat3();
586 
587  if ( hasMaster ) {
588  self->GetMasterPosition( masterOrigin, masterAxis );
589  current[id].localAxis *= rotation.ToMat3();
590  current[id].localOrigin = ( current[id].origin - masterOrigin ) * masterAxis.Transpose();
591  } else {
592  current[id].localAxis = current[id].axis;
593  current[id].localOrigin = current[id].origin;
594  }
595 
596  if ( clipModels[id] ) {
597  clipModels[id]->Link( gameLocal.clip, self, id, current[id].origin, current[id].axis );
598  }
599  } else if ( id == -1 ) {
600  for ( i = 0; i < clipModels.Num(); i++ ) {
601  current[i].origin *= rotation;
602  current[i].axis *= rotation.ToMat3();
603 
604  if ( hasMaster ) {
605  self->GetMasterPosition( masterOrigin, masterAxis );
606  current[i].localAxis *= rotation.ToMat3();
607  current[i].localOrigin = ( current[i].origin - masterOrigin ) * masterAxis.Transpose();
608  } else {
609  current[i].localAxis = current[i].axis;
610  current[i].localOrigin = current[i].origin;
611  }
612 
613  if ( clipModels[i] ) {
614  clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
615  }
616  }
617  }
618 }
619 
620 /*
621 ================
622 idPhysics_StaticMulti::GetOrigin
623 ================
624 */
625 const idVec3 &idPhysics_StaticMulti::GetOrigin( int id ) const {
626  if ( id >= 0 && id < clipModels.Num() ) {
627  return current[id].origin;
628  }
629  if ( clipModels.Num() ) {
630  return current[0].origin;
631  } else {
632  return vec3_origin;
633  }
634 }
635 
636 /*
637 ================
638 idPhysics_StaticMulti::GetAxis
639 ================
640 */
641 const idMat3 &idPhysics_StaticMulti::GetAxis( int id ) const {
642  if ( id >= 0 && id < clipModels.Num() ) {
643  return current[id].axis;
644  }
645  if ( clipModels.Num() ) {
646  return current[0].axis;
647  } else {
648  return mat3_identity;
649  }
650 }
651 
652 /*
653 ================
654 idPhysics_StaticMulti::SetLinearVelocity
655 ================
656 */
657 void idPhysics_StaticMulti::SetLinearVelocity( const idVec3 &newLinearVelocity, int id ) {
658 }
659 
660 /*
661 ================
662 idPhysics_StaticMulti::SetAngularVelocity
663 ================
664 */
665 void idPhysics_StaticMulti::SetAngularVelocity( const idVec3 &newAngularVelocity, int id ) {
666 }
667 
668 /*
669 ================
670 idPhysics_StaticMulti::GetLinearVelocity
671 ================
672 */
674  return vec3_origin;
675 }
676 
677 /*
678 ================
679 idPhysics_StaticMulti::GetAngularVelocity
680 ================
681 */
683  return vec3_origin;
684 }
685 
686 /*
687 ================
688 idPhysics_StaticMulti::SetGravity
689 ================
690 */
691 void idPhysics_StaticMulti::SetGravity( const idVec3 &newGravity ) {
692 }
693 
694 /*
695 ================
696 idPhysics_StaticMulti::GetGravity
697 ================
698 */
700  static idVec3 gravity( 0, 0, -g_gravity.GetFloat() );
701  return gravity;
702 }
703 
704 /*
705 ================
706 idPhysics_StaticMulti::GetGravityNormal
707 ================
708 */
710  static idVec3 gravity( 0, 0, -1 );
711  return gravity;
712 }
713 
714 /*
715 ================
716 idPhysics_StaticMulti::ClipTranslation
717 ================
718 */
719 void idPhysics_StaticMulti::ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const {
720  memset( &results, 0, sizeof( trace_t ) );
721  gameLocal.Warning( "idPhysics_StaticMulti::ClipTranslation called" );
722 }
723 
724 /*
725 ================
726 idPhysics_StaticMulti::ClipRotation
727 ================
728 */
729 void idPhysics_StaticMulti::ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const {
730  memset( &results, 0, sizeof( trace_t ) );
731  gameLocal.Warning( "idPhysics_StaticMulti::ClipRotation called" );
732 }
733 
734 /*
735 ================
736 idPhysics_StaticMulti::ClipContents
737 ================
738 */
740  int i, contents;
741 
742  contents = 0;
743  for ( i = 0; i < clipModels.Num(); i++ ) {
744  if ( clipModels[i] ) {
745  if ( model ) {
746  contents |= gameLocal.clip.ContentsModel( clipModels[i]->GetOrigin(), clipModels[i], clipModels[i]->GetAxis(), -1,
747  model->Handle(), model->GetOrigin(), model->GetAxis() );
748  } else {
749  contents |= gameLocal.clip.Contents( clipModels[i]->GetOrigin(), clipModels[i], clipModels[i]->GetAxis(), -1, NULL );
750  }
751  }
752  }
753  return contents;
754 }
755 
756 /*
757 ================
758 idPhysics_StaticMulti::DisableClip
759 ================
760 */
762  int i;
763 
764  for ( i = 0; i < clipModels.Num(); i++ ) {
765  if ( clipModels[i] ) {
766  clipModels[i]->Disable();
767  }
768  }
769 }
770 
771 /*
772 ================
773 idPhysics_StaticMulti::EnableClip
774 ================
775 */
777  int i;
778 
779  for ( i = 0; i < clipModels.Num(); i++ ) {
780  if ( clipModels[i] ) {
781  clipModels[i]->Enable();
782  }
783  }
784 }
785 
786 /*
787 ================
788 idPhysics_StaticMulti::UnlinkClip
789 ================
790 */
792  int i;
793 
794  for ( i = 0; i < clipModels.Num(); i++ ) {
795  if ( clipModels[i] ) {
796  clipModels[i]->Unlink();
797  }
798  }
799 }
800 
801 /*
802 ================
803 idPhysics_StaticMulti::LinkClip
804 ================
805 */
807  int i;
808 
809  for ( i = 0; i < clipModels.Num(); i++ ) {
810  if ( clipModels[i] ) {
811  clipModels[i]->Link( gameLocal.clip, self, i, current[i].origin, current[i].axis );
812  }
813  }
814 }
815 
816 /*
817 ================
818 idPhysics_StaticMulti::EvaluateContacts
819 ================
820 */
822  return false;
823 }
824 
825 /*
826 ================
827 idPhysics_StaticMulti::GetNumContacts
828 ================
829 */
831  return 0;
832 }
833 
834 /*
835 ================
836 idPhysics_StaticMulti::GetContact
837 ================
838 */
840  static contactInfo_t info;
841  memset( &info, 0, sizeof( info ) );
842  return info;
843 }
844 
845 /*
846 ================
847 idPhysics_StaticMulti::ClearContacts
848 ================
849 */
851 }
852 
853 /*
854 ================
855 idPhysics_StaticMulti::AddContactEntity
856 ================
857 */
859 }
860 
861 /*
862 ================
863 idPhysics_StaticMulti::RemoveContactEntity
864 ================
865 */
867 }
868 
869 /*
870 ================
871 idPhysics_StaticMulti::HasGroundContacts
872 ================
873 */
875  return false;
876 }
877 
878 /*
879 ================
880 idPhysics_StaticMulti::IsGroundEntity
881 ================
882 */
883 bool idPhysics_StaticMulti::IsGroundEntity( int entityNum ) const {
884  return false;
885 }
886 
887 /*
888 ================
889 idPhysics_StaticMulti::IsGroundClipModel
890 ================
891 */
892 bool idPhysics_StaticMulti::IsGroundClipModel( int entityNum, int id ) const {
893  return false;
894 }
895 
896 /*
897 ================
898 idPhysics_StaticMulti::SetPushed
899 ================
900 */
901 void idPhysics_StaticMulti::SetPushed( int deltaTime ) {
902 }
903 
904 /*
905 ================
906 idPhysics_StaticMulti::GetPushedLinearVelocity
907 ================
908 */
910  return vec3_origin;
911 }
912 
913 /*
914 ================
915 idPhysics_StaticMulti::GetPushedAngularVelocity
916 ================
917 */
919  return vec3_origin;
920 }
921 
922 /*
923 ================
924 idPhysics_StaticMulti::SetMaster
925 ================
926 */
927 void idPhysics_StaticMulti::SetMaster( idEntity *master, const bool orientated ) {
928  int i;
929  idVec3 masterOrigin;
930  idMat3 masterAxis;
931 
932  if ( master ) {
933  if ( !hasMaster ) {
934  // transform from world space to master space
935  self->GetMasterPosition( masterOrigin, masterAxis );
936  for ( i = 0; i < clipModels.Num(); i++ ) {
937  current[i].localOrigin = ( current[i].origin - masterOrigin ) * masterAxis.Transpose();
938  if ( orientated ) {
939  current[i].localAxis = current[i].axis * masterAxis.Transpose();
940  } else {
941  current[i].localAxis = current[i].axis;
942  }
943  }
944  hasMaster = true;
945  isOrientated = orientated;
946  }
947  } else {
948  if ( hasMaster ) {
949  hasMaster = false;
950  }
951  }
952 }
953 
954 /*
955 ================
956 idPhysics_StaticMulti::GetBlockingInfo
957 ================
958 */
960  return NULL;
961 }
962 
963 /*
964 ================
965 idPhysics_StaticMulti::GetBlockingEntity
966 ================
967 */
969  return NULL;
970 }
971 
972 /*
973 ================
974 idPhysics_StaticMulti::GetLinearEndTime
975 ================
976 */
978  return 0;
979 }
980 
981 /*
982 ================
983 idPhysics_StaticMulti::GetAngularEndTime
984 ================
985 */
987  return 0;
988 }
989 
990 /*
991 ================
992 idPhysics_StaticMulti::WriteToSnapshot
993 ================
994 */
996  int i;
997  idCQuat quat, localQuat;
998 
999  msg.WriteByte( current.Num() );
1000 
1001  for ( i = 0; i < current.Num(); i++ ) {
1002  quat = current[i].axis.ToCQuat();
1003  localQuat = current[i].localAxis.ToCQuat();
1004 
1005  msg.WriteFloat( current[i].origin[0] );
1006  msg.WriteFloat( current[i].origin[1] );
1007  msg.WriteFloat( current[i].origin[2] );
1008  msg.WriteFloat( quat.x );
1009  msg.WriteFloat( quat.y );
1010  msg.WriteFloat( quat.z );
1011  msg.WriteDeltaFloat( current[i].origin[0], current[i].localOrigin[0] );
1012  msg.WriteDeltaFloat( current[i].origin[1], current[i].localOrigin[1] );
1013  msg.WriteDeltaFloat( current[i].origin[2], current[i].localOrigin[2] );
1014  msg.WriteDeltaFloat( quat.x, localQuat.x );
1015  msg.WriteDeltaFloat( quat.y, localQuat.y );
1016  msg.WriteDeltaFloat( quat.z, localQuat.z );
1017  }
1018 }
1019 
1020 /*
1021 ================
1022 idPhysics_StaticMulti::ReadFromSnapshot
1023 ================
1024 */
1026  int i, num;
1027  idCQuat quat, localQuat;
1028 
1029  num = msg.ReadByte();
1030  assert( num == current.Num() );
1031 
1032  for ( i = 0; i < current.Num(); i++ ) {
1033  current[i].origin[0] = msg.ReadFloat();
1034  current[i].origin[1] = msg.ReadFloat();
1035  current[i].origin[2] = msg.ReadFloat();
1036  quat.x = msg.ReadFloat();
1037  quat.y = msg.ReadFloat();
1038  quat.z = msg.ReadFloat();
1039  current[i].localOrigin[0] = msg.ReadDeltaFloat( current[i].origin[0] );
1040  current[i].localOrigin[1] = msg.ReadDeltaFloat( current[i].origin[1] );
1041  current[i].localOrigin[2] = msg.ReadDeltaFloat( current[i].origin[2] );
1042  localQuat.x = msg.ReadDeltaFloat( quat.x );
1043  localQuat.y = msg.ReadDeltaFloat( quat.y );
1044  localQuat.z = msg.ReadDeltaFloat( quat.z );
1045 
1046  current[i].axis = quat.ToMat3();
1047  current[i].localAxis = localQuat.ToMat3();
1048  }
1049 }
const trace_t * GetBlockingInfo(void) const
int GetAngularEndTime(void) const
bool AddBounds(const idBounds &a)
Definition: Bounds.h:255
const contactInfo_t & GetContact(int num) const
int ClipContents(const idClipModel *model) const
assert(prefInfo.fullscreenBtn)
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
Definition: Quat.h:306
void WriteObject(const idClass *obj)
Definition: SaveGame.cpp:329
idClip clip
Definition: Game_local.h:296
GLenum GLint GLuint mask
Definition: glext.h:5864
void AddContactEntity(idEntity *e)
float GetFloat(void) const
Definition: CVarSystem.h:144
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
void Restore(idRestoreGame *savefile)
void RemoveContactEntity(idEntity *e)
idMat3 Transpose(void) const
Definition: Matrix.h:677
void AssureSize(int newSize)
Definition: List.h:445
void Save(idSaveGame *savefile) const
const idMat3 & GetAxis(int id=0) const
const idMat3 & GetAxis(void) const
Definition: Clip.h:210
void UpdateTime(int endTimeMSec)
const idBounds & GetAbsBounds(int id=-1) const
idBounds bounds_zero(vec3_zero, vec3_zero)
Definition: Vector.h:316
void ReadBool(bool &value)
Definition: SaveGame.cpp:976
static void DeletePhysics(const idPhysics *phys)
Definition: Force.cpp:62
const idVec3 & GetLinearVelocity(int id=0) const
const idVec3 & GetOrigin(void) const
Definition: Clip.h:206
void Clear(void)
Definition: Bounds.h:201
void WriteFloat(float f)
Definition: BitMsg.h:558
void Identity(void)
Definition: Matrix.h:591
bool IsGroundEntity(int entityNum) const
int GetNumContacts(void) const
int GetContents(int id=-1) const
void WriteClipModel(const class idClipModel *clipModel)
Definition: SaveGame.cpp:744
int i
Definition: process.py:33
GLuint GLuint num
Definition: glext.h:5390
void WriteVec3(const idVec3 &vec)
Definition: SaveGame.cpp:253
void SetMass(float mass, int id=-1)
bool Evaluate(int timeStepMSec, int endTimeMSec)
void WriteBool(const bool value)
Definition: SaveGame.cpp:222
bool IsGroundClipModel(int entityNum, int id) const
void void void Warning(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:735
const idVec3 & GetOrigin(int id=0) const
END_CLASS staticPState_t defaultState
const idVec3 & GetGravity(void) const
idPhysics * GetPhysics(void) const
Definition: Entity.cpp:2607
void SetMaster(idEntity *master, const bool orientated=true)
void WriteDeltaFloat(float oldValue, float newValue)
Definition: BitMsg.h:595
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
void ApplyImpulse(const int id, const idVec3 &point, const idVec3 &impulse)
idCVar g_gravity("g_gravity", DEFAULT_GRAVITY_STRING, CVAR_GAME|CVAR_FLOAT,"")
void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)
cmHandle_t Handle(void) const
Definition: Clip.cpp:457
#define NULL
Definition: Lib.h:88
bool IsPushable(void) const
idClipModel * DefaultClipModel(void)
Definition: Clip.h:348
void GetImpactInfo(const int id, const idVec3 &point, impactInfo_t *info) const
void AddForce(const int id, const idVec3 &point, const idVec3 &force)
float z
Definition: Quat.h:310
float ReadDeltaFloat(float oldValue) const
Definition: BitMsg.h:664
void WriteByte(int c)
Definition: BitMsg.h:542
bool HasGroundContacts(void) const
idGameLocal gameLocal
Definition: Game_local.cpp:64
#define END_CLASS
Definition: Class.h:54
idEntity * GetBlockingEntity(void) const
idList< idClipModel * > clipModels
const idVec3 & GetAngularVelocity(int id=0) const
void WriteInt(const int value)
Definition: SaveGame.cpp:168
void SetClipMask(int mask, int id=-1)
float x
Definition: Quat.h:308
int GetRestStartTime(void) const
void WriteMat3(const idMat3 &mat)
Definition: SaveGame.cpp:309
void Rotate(const idRotation &rotation, int id=-1)
void ReadMat3(idMat3 &mat)
Definition: SaveGame.cpp:1064
void SetAxis(const idMat3 &newAxis, int id=-1)
void ClipTranslation(trace_t &results, const idVec3 &translation, const idClipModel *model) const
idList< staticPState_t > current
const idBounds & GetBounds(int id=-1) const
void ReadClipModel(idClipModel *&clipModel)
Definition: SaveGame.cpp:1519
Definition: Matrix.h:333
const idVec3 & GetGravityNormal(void) const
GLuint id
Definition: glext.h:3103
void SetOrigin(const idVec3 &rotationOrigin)
Definition: Rotation.h:115
idMat3 ToMat3(void) const
Definition: Quat.cpp:232
int GetLinearEndTime(void) const
const idMat3 & ToMat3(void) const
Definition: Rotation.cpp:60
int Num(void) const
Definition: List.h:265
bool RemoveIndex(int index)
Definition: List.h:849
void WriteToSnapshot(idBitMsgDelta &msg) const
int Contents(const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity)
Definition: Clip.cpp:1429
int ContentsModel(const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
Definition: Clip.cpp:1532
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
Definition: Class.h:110
int ReadByte(void) const
Definition: BitMsg.h:609
void ReadVec3(idVec3 &vec)
Definition: SaveGame.cpp:1011
idRotation ToRotation(void) const
Definition: Matrix.cpp:246
void RemoveIndex(int id=0, bool freeClipModel=true)
float y
Definition: Quat.h:309
float ReadFloat(void) const
Definition: BitMsg.h:625
void Translate(const idVec3 &translation, int id=-1)
int GetClipMask(int id=-1) const
float GetMass(int id=-1) const
void ClipRotation(trace_t &results, const idRotation &rotation, const idClipModel *model) const
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetGravity(const idVec3 &newGravity)
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
void SetPushed(int deltaTime)
void Zero(void)
Definition: Vector.h:415
int GetNumClipModels(void) const
void ReadInt(int &value)
Definition: SaveGame.cpp:922
const idVec3 & GetPushedAngularVelocity(const int id=0) const
const idVec3 & GetPushedLinearVelocity(const int id=0) const
void SetContents(int contents, int id=-1)
idClipModel * GetClipModel(int id=0) const
void SetOrigin(const idVec3 &newOrigin, int id=-1)
void ReadObject(idClass *&obj)
Definition: SaveGame.cpp:1083