29 #include "../../idlib/precompiled.h"
32 #include "../Game_local.h"
54 if (
pushed[i].ent == ent ) {
68 if ( ent->
IsType( idActor::Type ) ) {
90 if (
pushed[i].ent->IsType( idActor::Type ) ) {
118 for ( i = 0; i < 4; i++ ) {
121 rotation.
Scale( -1 );
124 if ( rotation.
GetAngle() == 0.0f ) {
144 rotationPoint = trace.
c.
point;
169 if ( ent->client && ent->client->noclip ) {
193 void idPush::AddEntityToPushedGroup(
idEntity *ent,
float fraction,
bool groundContact ) {
206 for ( j = pushedGroupSize; j >
i; j-- ) {
237 bool idPush::IsFullyPushed(
idEntity *ent ) {
263 for ( i = 0; i <
n; i++ ) {
277 int idPush::GetPushableEntitiesForTranslation(
idEntity *pusher,
idEntity *initialPusher,
const int flags,
278 const idVec3 &translation,
idEntity *entityList[],
int maxEntities ) {
292 for ( l = i = 0; i <
n; i++ ) {
293 if ( entityList[i] == pusher || entityList[i] == initialPusher ) {
296 if ( CanPushEntity( entityList[i], pusher, initialPusher, flags ) ) {
297 entityList[l++] = entityList[
i];
313 int i,
j, numListedEntities;
316 bool groundContact, blocked =
false;
319 idVec3 realTranslation, partialTranslation;
324 results.
endpos = newOrigin;
326 memset( results.
c, 0,
sizeof( results.
c ) );
335 numListedEntities = GetPushableEntitiesForTranslation( pusher, pusher, flags, translation, entityList,
MAX_GENTITIES );
337 for ( i = 0; i < numListedEntities; i++ ) {
343 for ( i = 0; i < numListedEntities; i++ ) {
349 realTranslation = results.
fraction * translation;
352 realTranslation = translation;
374 numListedEntities = GetPushableEntitiesForTranslation( curPusher, pusher, flags, realTranslation, entityList,
MAX_GENTITIES );
376 for ( j = 0; j < numListedEntities; j++ ) {
377 ent = entityList[
j ];
379 if ( IsFullyPushed( ent ) ) {
383 if ( !CanPushEntity( ent, curPusher, pusher, flags ) ) {
388 AddEntityToPushedGroup( ent, 1.0
f * fraction,
false );
390 else if ( ClipTranslationAgainstPusher( trace, ent, curPusher, -fraction * realTranslation ) ) {
391 AddEntityToPushedGroup( ent, ( 1.0
f - trace.
fraction ) * fraction, groundContact );
421 if ( flags & PUSHFL_CLIP ) {
459 for ( i = 0; i <
n; i++ ) {
473 int idPush::GetPushableEntitiesForRotation(
idEntity *pusher,
idEntity *initialPusher,
const int flags,
488 for ( l = i = 0; i <
n; i++ ) {
489 if ( entityList[i] == pusher || entityList[i] == initialPusher ) {
492 if ( CanPushEntity( entityList[i], pusher, initialPusher, flags ) ) {
493 entityList[l++] = entityList[
i];
509 int i,
j, numListedEntities;
512 bool groundContact, blocked =
false;
523 memset( results.
c, 0,
sizeof( results.
c ) );
530 if ( flags & PUSHFL_CLIP ) {
532 numListedEntities = GetPushableEntitiesForRotation( pusher, pusher, flags, rotation, entityList,
MAX_GENTITIES );
534 for ( i = 0; i < numListedEntities; i++ ) {
540 for ( i = 0; i < numListedEntities; i++ ) {
546 realRotation = results.
fraction * rotation;
549 realRotation = rotation;
571 numListedEntities = GetPushableEntitiesForRotation( curPusher, pusher, flags, realRotation, entityList,
MAX_GENTITIES );
573 for ( j = 0; j < numListedEntities; j++ ) {
574 ent = entityList[
j ];
576 if ( IsFullyPushed( ent ) ) {
581 AddEntityToPushedGroup( ent, 1.0
f * fraction,
false );
583 else if ( ClipRotationAgainstPusher( trace, ent, curPusher, -fraction * realRotation ) ) {
584 AddEntityToPushedGroup( ent, ( 1.0
f - trace.
fraction ) * fraction, groundContact );
614 if ( flags & PUSHFL_CLIP ) {
718 #ifdef ROTATIONAL_PUSH_DEBUG
719 bool startsolid =
false;
728 memset( &results.
c, 0,
sizeof( results.
c ) );
763 newRotation = rotation;
764 newRotation.
Scale( -1 );
769 #ifdef ROTATIONAL_PUSH_DEBUG
781 rotationPoint = results.
c.
point;
805 static float shit = checkAngle;
810 physics->
Rotate( newRotation );
815 #ifdef ROTATIONAL_PUSH_DEBUG
824 if ( physics->
IsType( idPhysics_Actor::Type ) ) {
833 #ifdef ROTATIONAL_PUSH_DEBUG
842 if ( check->
IsType( idActor::Type ) && physics->
IsType( idPhysics_Actor::Type ) ) {
849 delta.
yaw += newRotation.
ToMat3()[0].ToYaw();
875 #ifdef TRANSLATIONAL_PUSH_DEBUG
876 bool startsolid =
false;
883 results.
endpos = newOrigin;
885 memset( &results.
c, 0,
sizeof( results.
c ) );
922 checkMove = move * (1.0f - results.
fraction);
975 #ifdef TRANSLATIONAL_PUSH_DEBUG
998 for ( num = i = 0; i < numEntities; i++ ) {
999 check = entityList[
i ];
1012 if ( check->
IsType( idPlayer::Type ) &&
static_cast<idPlayer *
>(check)->noclip ) {
1017 if ( ( flags & PUSHFL_ONLYMOVEABLE ) && !check->
IsType( idMoveable::Type ) ) {
1022 if ( flags & PUSHFL_NOGROUNDENTITIES ) {
1029 entityList[ num++ ] = entityList[
i];
1044 int i, listedEntities,
res;
1047 idVec3 clipMove, clipOrigin, oldOrigin, dir, impulse;
1058 results.
endpos = newOrigin;
1060 memset( &results.
c, 0,
sizeof( results.
c ) );
1073 if ( bounds[0].
x >= bounds[1].
x ) {
1086 listedEntities =
DiscardEntities( entityList, listedEntities, flags, pusher );
1088 if ( flags & PUSHFL_CLIP ) {
1094 for ( i = 0; i < listedEntities; i++ ) {
1101 for ( i = 0; i < listedEntities; i++ ) {
1107 clipModel->Enable();
1112 clipMove = results.
endpos - clipModel->GetOrigin();
1113 clipOrigin = results.
endpos;
1118 clipMove = translation;
1119 clipOrigin = newOrigin;
1129 for ( i = 0; i < listedEntities; i++ ) {
1131 check = entityList[
i ];
1154 impulse = physics->
GetMass() * dir;
1161 totalMass += physics->
GetMass();
1170 if ( check->
IsType( idProjectile::Type ) ) {
1183 if ( static_cast<idAFEntity_Base *>(check)->IsActiveAF() ) {
1194 results = pushResults;
1201 if ( !wasEnabled ) {
1208 if ( !wasEnabled ) {
1224 int i, listedEntities,
res;
1228 idMat3 clipAxis, oldAxis;
1241 memset( &results.
c, 0,
sizeof( results.
c ) );
1249 if ( bounds[0].
x >= bounds[1].
x ) {
1262 listedEntities =
DiscardEntities( entityList, listedEntities, flags, pusher );
1264 if ( flags & PUSHFL_CLIP ) {
1270 for ( i = 0; i < listedEntities; i++ ) {
1277 for ( i = 0; i < listedEntities; i++ ) {
1283 clipModel->Enable();
1288 clipRotation = rotation * results.
fraction;
1293 clipRotation = rotation;
1301 oldAxis = clipModel->
GetAxis();
1304 for ( i = 0; i < listedEntities; i++ ) {
1306 check = entityList[
i ];
1313 res =
TryRotatePushEntity( pushResults, check, clipModel, flags, clipAxis, clipRotation );
1331 totalMass += physics->
GetMass();
1340 if ( check->
IsType( idProjectile::Type ) ) {
1353 if ( static_cast<idAFEntity_Base *>(check)->IsActiveAF() ) {
1359 results = pushResults;
1366 if ( !wasEnabled ) {
1373 if ( !wasEnabled ) {
1400 results.
endpos = newOrigin;
1402 memset( &results.
c, 0,
sizeof( results.
c ) );
1405 translation = newOrigin - oldOrigin;
1412 newOrigin = oldOrigin;
1417 newOrigin = oldOrigin;
1421 rotation = ( oldAxis.
Transpose() * newAxis ).ToRotation();
1427 if ( rotation.
GetAngle() != 0.0f ) {
1430 newAxis = oldAxis * rotation.
ToMat3();
1439 newOrigin = oldOrigin;
virtual const idVec3 & GetOrigin(int id=0) const =0
idEntity * GetEntity(void) const
void ClipEntityTranslation(trace_t &trace, const idEntity *ent, const idClipModel *clipModel, idClipModel *skip, const idVec3 &translation)
float ClipPush(trace_t &results, idEntity *pusher, const int flags, const idVec3 &oldOrigin, const idMat3 &oldAxis, idVec3 &newOrigin, idMat3 &newAxis)
virtual void EnableClip(void)=0
assert(prefInfo.fullscreenBtn)
#define CLIPMODEL_ID_TO_JOINT_HANDLE(id)
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
virtual int GetClipMask(int id=-1) const =0
bool IsEnabled(void) const
virtual void SaveState(void)=0
void ClipEntityRotation(trace_t &trace, const idEntity *ent, const idClipModel *clipModel, idClipModel *skip, const idRotation &rotation)
virtual void Rotate(const idRotation &rotation, int id=-1)=0
void Translate(const idVec3 &translation)
void SaveEntityPosition(idEntity *ent)
idMat3 Transpose(void) const
void InitSavingPushedEntityPositions(void)
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
bool IsType(const idTypeInfo &c) const
const idMat3 & GetAxis(void) const
const idEventDef EV_Gib("gib","s")
bool ProcessEvent(const idEventDef *ev)
virtual int GetNumClipModels(void) const =0
float ClipTranslationalPush(trace_t &results, idEntity *pusher, const int flags, const idVec3 &newOrigin, const idVec3 &move)
virtual void Translate(const idVec3 &translation, int id=-1)=0
#define PUSHFL_NOGROUNDENTITIES
const idVec3 & GetOrigin(void) const
void Scale(const float s)
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
bool IsRotated(void) const
virtual bool IsGroundClipModel(int entityNum, int id) const =0
void FromBoundsRotation(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idRotation &rotation)
void RestorePushedEntityPositions(void)
void SetDeltaViewAngles(const idAngles &delta)
virtual void RestoreState(void)=0
const idEventDef EV_Explode("<explode>", NULL)
int EntitiesTouchingBounds(const idBounds &bounds, int contentMask, idEntity **entityList, int maxCount) const
virtual const idBounds & GetBounds(int id=-1) const =0
#define PUSHFL_ONLYMOVEABLE
void FromBoundsTranslation(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idVec3 &translation)
float GetAngle(void) const
virtual void ClipTranslation(trace_t &results, const idVec3 &translation, const idClipModel *model) const =0
idPhysics * GetPhysics(void) const
int TryTranslatePushEntity(trace_t &results, idEntity *check, idClipModel *clipModel, const int flags, const idVec3 &newOrigin, const idVec3 &move)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
const idAngles & GetDeltaViewAngles(void) const
bool RotateEntityToAxial(idEntity *ent, idVec3 rotationPoint)
virtual float GetMass(int id=-1) const =0
bool GetBool(const char *key, const char *defaultString="0") const
const idBounds & GetBounds(void) const
virtual void SetOrigin(const idVec3 &newOrigin, int id=-1)=0
bool IsTraceModel(void) const
virtual const idMat3 & GetAxis(int id=0) const =0
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
#define PUSHFL_APPLYIMPULSE
idMat3 & OrthoNormalizeSelf(void)
void Set(const idVec3 &rotationOrigin, const idVec3 &rotationVec, const float rotationAngle)
virtual void DisableClip(void)=0
virtual idClipModel * GetClipModel(int id=0) const =0
int DiscardEntities(idEntity *entityList[], int numEntities, int flags, idEntity *pusher)
const idVec3 & GetVec(void) const
int TryRotatePushEntity(trace_t &results, idEntity *check, idClipModel *clipModel, const int flags, const idMat3 &newAxis, const idRotation &rotation)
void SetOrigin(const idVec3 &rotationOrigin)
virtual bool IsPushable(void) const =0
virtual void ClipRotation(trace_t &results, const idRotation &rotation, const idClipModel *model) const =0
const idMat3 & ToMat3(void) const
virtual bool IsGroundEntity(int entityNum) const =0
bool Rotation(trace_t &results, const idVec3 &start, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity)
virtual int ClipContents(const idClipModel *model) const =0
void ReCalculateMatrix(void)
idRotation ToRotation(void) const
virtual bool EvaluateContacts(void)=0
const idVec3 & GetOrigin(void) const
virtual int GetContents(int id=-1) const =0
idBounds & ExpandSelf(const float d)
void Rotate(const idRotation &rotation)
struct idPush::pushedGroup_s pushedGroup[MAX_GENTITIES]
bool Translation(trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity)
bool FixDegeneracies(void)
void SetPosition(const idVec3 &newOrigin, const idMat3 &newAxis)
void RotatePoint(idVec3 &point) const
struct idPush::pushed_s pushed[MAX_GENTITIES]
virtual void SetAxis(const idMat3 &newAxis, int id=-1)=0
float ClipRotationalPush(trace_t &results, idEntity *pusher, const int flags, const idMat3 &newAxis, const idRotation &rotation)