Skip to content

Commit fe7cf48

Browse files
ShokerStlkXottab-DUTY
authored andcommitted
SWM: Ported xrPhysics
1 parent 3d65f4a commit fe7cf48

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

src/xrGame/PhysicsShellHolder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ LPCSTR CPhysicsShellHolder::ObjectNameSect() const { return cNameSect().c_str();
461461
bool CPhysicsShellHolder::ObjectGetDestroy() const { return !!CGameObject::getDestroy(); }
462462
ICollisionHitCallback* CPhysicsShellHolder::ObjectGetCollisionHitCallback() { return get_collision_hit_callback(); }
463463
u16 CPhysicsShellHolder::ObjectID() const { return ID(); }
464+
465+
IGameObject* CPhysicsShellHolder::IObject() //--#SM+#--
466+
{
467+
return smart_cast<IGameObject*>(this);
468+
}
469+
464470
ICollisionForm* CPhysicsShellHolder::ObjectCollisionModel()
465471
{
466472
return CForm; // XXX: use ICollidable::GetCForm() instead
@@ -498,6 +504,9 @@ IPHCapture* CPhysicsShellHolder::PHCapture()
498504
bool CPhysicsShellHolder::IsInventoryItem() { return !!cast_inventory_item(); }
499505
bool CPhysicsShellHolder::IsActor() { return !!cast_actor(); }
500506
bool CPhysicsShellHolder::IsStalker() { return !!cast_stalker(); }
507+
bool CPhysicsShellHolder::IsCollideWithBullets() { return true; }
508+
bool CPhysicsShellHolder::IsCollideWithActorCamera() { return true; }
509+
501510
// void SetWeaponHideState( u16 State, bool bSet )
502511
void CPhysicsShellHolder::HideAllWeapons(bool v) {}
503512
void CPhysicsShellHolder::MovementCollisionEnable(bool enable)

src/xrGame/PhysicsShellHolder.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#pragma once
2-
#ifndef PHYSICSSHELL_HOLDER_H
3-
#define PHYSICSSHELL_HOLDER_H
42

53
#include "GameObject.h"
64
#include "ParticlesPlayer.h"
7-
#include "xrEngine/iobjectphysicscollision.h"
8-
#include "xrPhysics/iphysicsshellholder.h"
5+
#include "xrEngine/IObjectPhysicsCollision.h"
6+
#include "xrPhysics/IPhysicsShellHolder.h"
97

108
class CPHDestroyable;
119
class CPHCollisionDamageReceiver;
@@ -118,6 +116,7 @@ class CPhysicsShellHolder : public CGameObject,
118116
virtual bool ObjectGetDestroy() const;
119117
virtual ICollisionHitCallback* ObjectGetCollisionHitCallback();
120118
virtual u16 ObjectID() const;
119+
virtual IGameObject* IObject(); //--#SM+#--
121120
virtual ICollisionForm* ObjectCollisionModel();
122121
// virtual IRenderVisual* ObjectVisual () ;
123122
virtual IKinematics* ObjectKinematics();
@@ -133,6 +132,8 @@ class CPhysicsShellHolder : public CGameObject,
133132
virtual bool IsInventoryItem();
134133
virtual bool IsActor();
135134
virtual bool IsStalker();
135+
virtual bool IsCollideWithBullets(); //--#SM+#--
136+
virtual bool IsCollideWithActorCamera(); //--#SM+#--
136137
// virtual void SetWeaponHideState ( u16 State, bool bSet )=0;
137138
virtual void HideAllWeapons(bool v); //(SetWeaponHideState(INV_STATE_BLOCK_ALL,true))
138139
virtual void MovementCollisionEnable(bool enable);
@@ -144,4 +145,3 @@ class CPhysicsShellHolder : public CGameObject,
144145
#endif
145146
};
146147

147-
#endif

src/xrPhysics/ActorCameraCollision.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#include "stdafx.h"
22

3-
#include "actorcameracollision.h"
3+
#include "ActorCameraCollision.h"
44

55
#include "xrEngine/CameraBase.h"
66
#include "xrEngine/GameMtlLib.h"
77

8-
#include "phworld.h"
9-
#include "phcollidevalidator.h"
8+
#include "PHWorld.h"
9+
#include "PHCollideValidator.h"
1010
#include "PHShell.h"
1111
#include "matrix_utils.h"
12-
#include "iphysicsshellholder.h"
13-
12+
#include "IPhysicsShellHolder.h"
13+
#include "xrEngine/xr_object.h" //--#SM+#--
1414
#include "GeometryBits.h"
1515

1616
#ifdef DEBUG
@@ -43,6 +43,9 @@ static void cammera_shell_collide_callback_common(
4343
VERIFY(my_data);
4444
if (oposite_data && oposite_data->ph_ref_object == my_data->ph_ref_object)
4545
return;
46+
if (oposite_data && oposite_data->ph_ref_object &&
47+
!oposite_data->ph_ref_object->IsCollideWithActorCamera()) //--#SM+#--
48+
return;
4649
if (c.geom.depth > camera_collision_sckin_depth / 2.f)
4750
cam_collided = true;
4851

@@ -316,6 +319,19 @@ bool test_camera_box(const Fvector& box_size, const Fmatrix& xform, IPhysicsShel
316319
return ret;
317320
}
318321

322+
// Test only, generate box from camera --#SM+#--
323+
bool test_camera_collide(
324+
CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor, Fvector& vPosOffset, float fBoxSizeMod)
325+
{
326+
Fvector box_size;
327+
Fmatrix xform;
328+
get_camera_box(box_size, xform, camera, _viewport_near);
329+
box_size.mul(fBoxSizeMod);
330+
xform.c.mad(camera.Direction(), vPosOffset);
331+
332+
return test_camera_box(box_size, xform, l_actor);
333+
}
334+
319335
void collide_camera(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor)
320336
{
321337
// CPhysicsShellHolder* l_actor = smart_cast<CPhysicsShellHolder*>( Level().CurrentEntity() );

src/xrPhysics/ActorCameraCollision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ extern XRPHYSICS_API float camera_collision_character_skin_depth;
99
extern XRPHYSICS_API float camera_collision_character_shift_z;
1010
#endif
1111
XRPHYSICS_API bool test_camera_box(const Fvector& box_size, const Fmatrix& xform, IPhysicsShellHolder* l_actor);
12+
XRPHYSICS_API bool test_camera_collide(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor, Fvector& vPosOffset, float fBoxSizeMod); //--#SM+#--
1213
XRPHYSICS_API void collide_camera(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor);

src/xrPhysics/IPhysicsShellHolder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class IPhysicsShellHolder;
1010
class CPHSoundPlayer;
1111
class ICollisionDamageReceiver;
1212
class ICollisionForm;
13+
class IGameObject; //--#SM+#--
14+
1315
class ICollisionHitCallback
1416
{
1517
public:
@@ -41,6 +43,7 @@ class IPhysicsShellHolder
4143
virtual bool ObjectGetDestroy() const = 0;
4244
virtual ICollisionHitCallback* ObjectGetCollisionHitCallback() = 0;
4345
virtual u16 ObjectID() const = 0;
46+
virtual IGameObject* IObject() = 0; //--#SM+#--
4447
virtual ICollisionForm* ObjectCollisionModel() = 0;
4548
// virtual IRenderVisual* ObjectVisual () =0;
4649
virtual IKinematics* ObjectKinematics() = 0;
@@ -56,6 +59,8 @@ class IPhysicsShellHolder
5659
virtual bool IsInventoryItem() = 0;
5760
virtual bool IsActor() = 0;
5861
virtual bool IsStalker() = 0;
62+
virtual bool IsCollideWithBullets() = 0; //--#SM+#--
63+
virtual bool IsCollideWithActorCamera() = 0; //--#SM+#--
5964
// virtual void SetWeaponHideState ( u16 State, bool bSet )=0;
6065
virtual void HideAllWeapons(bool v) = 0; //(SetWeaponHideState(INV_STATE_BLOCK_ALL,true))
6166
virtual void MovementCollisionEnable(bool enable) = 0;

0 commit comments

Comments
 (0)