Skip to content

Commit

Permalink
SWM: Ported xrPhysics
Browse files Browse the repository at this point in the history
  • Loading branch information
ShokerStlk authored and Xottab-DUTY committed Mar 30, 2018
1 parent 3d65f4a commit fe7cf48
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/xrGame/PhysicsShellHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ LPCSTR CPhysicsShellHolder::ObjectNameSect() const { return cNameSect().c_str();
bool CPhysicsShellHolder::ObjectGetDestroy() const { return !!CGameObject::getDestroy(); }
ICollisionHitCallback* CPhysicsShellHolder::ObjectGetCollisionHitCallback() { return get_collision_hit_callback(); }
u16 CPhysicsShellHolder::ObjectID() const { return ID(); }

IGameObject* CPhysicsShellHolder::IObject() //--#SM+#--
{
return smart_cast<IGameObject*>(this);
}

ICollisionForm* CPhysicsShellHolder::ObjectCollisionModel()
{
return CForm; // XXX: use ICollidable::GetCForm() instead
Expand Down Expand Up @@ -498,6 +504,9 @@ IPHCapture* CPhysicsShellHolder::PHCapture()
bool CPhysicsShellHolder::IsInventoryItem() { return !!cast_inventory_item(); }
bool CPhysicsShellHolder::IsActor() { return !!cast_actor(); }
bool CPhysicsShellHolder::IsStalker() { return !!cast_stalker(); }
bool CPhysicsShellHolder::IsCollideWithBullets() { return true; }
bool CPhysicsShellHolder::IsCollideWithActorCamera() { return true; }

// void SetWeaponHideState( u16 State, bool bSet )
void CPhysicsShellHolder::HideAllWeapons(bool v) {}
void CPhysicsShellHolder::MovementCollisionEnable(bool enable)
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/PhysicsShellHolder.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#pragma once
#ifndef PHYSICSSHELL_HOLDER_H
#define PHYSICSSHELL_HOLDER_H

#include "GameObject.h"
#include "ParticlesPlayer.h"
#include "xrEngine/iobjectphysicscollision.h"
#include "xrPhysics/iphysicsshellholder.h"
#include "xrEngine/IObjectPhysicsCollision.h"
#include "xrPhysics/IPhysicsShellHolder.h"

class CPHDestroyable;
class CPHCollisionDamageReceiver;
Expand Down Expand Up @@ -118,6 +116,7 @@ class CPhysicsShellHolder : public CGameObject,
virtual bool ObjectGetDestroy() const;
virtual ICollisionHitCallback* ObjectGetCollisionHitCallback();
virtual u16 ObjectID() const;
virtual IGameObject* IObject(); //--#SM+#--
virtual ICollisionForm* ObjectCollisionModel();
// virtual IRenderVisual* ObjectVisual () ;
virtual IKinematics* ObjectKinematics();
Expand All @@ -133,6 +132,8 @@ class CPhysicsShellHolder : public CGameObject,
virtual bool IsInventoryItem();
virtual bool IsActor();
virtual bool IsStalker();
virtual bool IsCollideWithBullets(); //--#SM+#--
virtual bool IsCollideWithActorCamera(); //--#SM+#--
// virtual void SetWeaponHideState ( u16 State, bool bSet )=0;
virtual void HideAllWeapons(bool v); //(SetWeaponHideState(INV_STATE_BLOCK_ALL,true))
virtual void MovementCollisionEnable(bool enable);
Expand All @@ -144,4 +145,3 @@ class CPhysicsShellHolder : public CGameObject,
#endif
};

#endif
26 changes: 21 additions & 5 deletions src/xrPhysics/ActorCameraCollision.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "stdafx.h"

#include "actorcameracollision.h"
#include "ActorCameraCollision.h"

#include "xrEngine/CameraBase.h"
#include "xrEngine/GameMtlLib.h"

#include "phworld.h"
#include "phcollidevalidator.h"
#include "PHWorld.h"
#include "PHCollideValidator.h"
#include "PHShell.h"
#include "matrix_utils.h"
#include "iphysicsshellholder.h"

#include "IPhysicsShellHolder.h"
#include "xrEngine/xr_object.h" //--#SM+#--
#include "GeometryBits.h"

#ifdef DEBUG
Expand Down Expand Up @@ -43,6 +43,9 @@ static void cammera_shell_collide_callback_common(
VERIFY(my_data);
if (oposite_data && oposite_data->ph_ref_object == my_data->ph_ref_object)
return;
if (oposite_data && oposite_data->ph_ref_object &&
!oposite_data->ph_ref_object->IsCollideWithActorCamera()) //--#SM+#--
return;
if (c.geom.depth > camera_collision_sckin_depth / 2.f)
cam_collided = true;

Expand Down Expand Up @@ -316,6 +319,19 @@ bool test_camera_box(const Fvector& box_size, const Fmatrix& xform, IPhysicsShel
return ret;
}

// Test only, generate box from camera --#SM+#--
bool test_camera_collide(
CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor, Fvector& vPosOffset, float fBoxSizeMod)
{
Fvector box_size;
Fmatrix xform;
get_camera_box(box_size, xform, camera, _viewport_near);
box_size.mul(fBoxSizeMod);
xform.c.mad(camera.Direction(), vPosOffset);

return test_camera_box(box_size, xform, l_actor);
}

void collide_camera(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor)
{
// CPhysicsShellHolder* l_actor = smart_cast<CPhysicsShellHolder*>( Level().CurrentEntity() );
Expand Down
1 change: 1 addition & 0 deletions src/xrPhysics/ActorCameraCollision.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ extern XRPHYSICS_API float camera_collision_character_skin_depth;
extern XRPHYSICS_API float camera_collision_character_shift_z;
#endif
XRPHYSICS_API bool test_camera_box(const Fvector& box_size, const Fmatrix& xform, IPhysicsShellHolder* l_actor);
XRPHYSICS_API bool test_camera_collide(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor, Fvector& vPosOffset, float fBoxSizeMod); //--#SM+#--
XRPHYSICS_API void collide_camera(CCameraBase& camera, float _viewport_near, IPhysicsShellHolder* l_actor);
5 changes: 5 additions & 0 deletions src/xrPhysics/IPhysicsShellHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class IPhysicsShellHolder;
class CPHSoundPlayer;
class ICollisionDamageReceiver;
class ICollisionForm;
class IGameObject; //--#SM+#--

class ICollisionHitCallback
{
public:
Expand Down Expand Up @@ -41,6 +43,7 @@ class IPhysicsShellHolder
virtual bool ObjectGetDestroy() const = 0;
virtual ICollisionHitCallback* ObjectGetCollisionHitCallback() = 0;
virtual u16 ObjectID() const = 0;
virtual IGameObject* IObject() = 0; //--#SM+#--
virtual ICollisionForm* ObjectCollisionModel() = 0;
// virtual IRenderVisual* ObjectVisual () =0;
virtual IKinematics* ObjectKinematics() = 0;
Expand All @@ -56,6 +59,8 @@ class IPhysicsShellHolder
virtual bool IsInventoryItem() = 0;
virtual bool IsActor() = 0;
virtual bool IsStalker() = 0;
virtual bool IsCollideWithBullets() = 0; //--#SM+#--
virtual bool IsCollideWithActorCamera() = 0; //--#SM+#--
// virtual void SetWeaponHideState ( u16 State, bool bSet )=0;
virtual void HideAllWeapons(bool v) = 0; //(SetWeaponHideState(INV_STATE_BLOCK_ALL,true))
virtual void MovementCollisionEnable(bool enable) = 0;
Expand Down

0 comments on commit fe7cf48

Please sign in to comment.