Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SNMetamorph committed Sep 2, 2023
1 parent fa6af65 commit 106efa2
Show file tree
Hide file tree
Showing 21 changed files with 1,371 additions and 1,261 deletions.
4 changes: 2 additions & 2 deletions common/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ GNU General Public License for more details.
#define FORCEINLINE __forceinline
#endif

#define open _open
#define read _read
//#define open _open
//#define read _read
#define alloca _alloca

#define WIN32_LEAN_AND_MEAN
Expand Down
2 changes: 1 addition & 1 deletion game_shared/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class matrix4x4
}

// init from OpenGl matrix
matrix4x4( float *opengl_matrix )
matrix4x4( const float *opengl_matrix )
{
mat[0][0] = opengl_matrix[0];
mat[0][1] = opengl_matrix[1];
Expand Down
14 changes: 10 additions & 4 deletions game_shared/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ GNU General Public License for more details.
*/
#ifdef USE_PHYSICS_ENGINE
#include "vector.h"
#include "NxVec3.h"
#include "PxVec3.h"

Vector :: Vector( const NxVec3& v )
Vector::Vector(const physx::PxVec3& v)
{
x = v.x; y = v.y; z = v.z;
}

const Vector& Vector :: operator = ( const NxVec3& v )
const Vector& Vector :: operator = (const physx::PxVec3& v)
{
x = v.x; y = v.y; z = v.z;
return *this;
}
#endif

Vector::operator physx::PxVec3() const
{
return physx::PxVec3(x, y, z);
}

#endif
19 changes: 10 additions & 9 deletions game_shared/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#pragma warning( disable : 4244 ) // disable 'possible loss of data converting float to int' warning message
#pragma warning( disable : 4305 ) // disable 'truncation from 'const double' to 'float' warning message

class NxVec3;
namespace physx {
class PxVec3;
};
class Radian;

inline void SinCos( float angle, float *sine, float *cosine )
Expand Down Expand Up @@ -126,8 +128,6 @@ typedef Vector2D vec2_t;
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }

class NxVec3;

//=========================================================
// 3D Vector
//=========================================================
Expand All @@ -141,7 +141,7 @@ class Vector // same data-layout as engine's vec3_t,
inline Vector( const float *rgfl ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
inline Vector( float fill ) { x = fill; y = fill; z = fill; }
Vector(const NxVec3& v);
Vector(const physx::PxVec3& v);

// Initialization
void Init(float ix=0.0f, float iy=0.0f, float iz=0.0f){ x = ix; y = iy; z = iz; }
Expand All @@ -157,8 +157,11 @@ class Vector // same data-layout as engine's vec3_t,
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
inline Vector operator*(const Vector& v) const { return Vector(x*v.x, y*v.y, z*v.z); }
const Vector& operator=(const NxVec3& v);

operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
operator const float *() const { return &x; }
const Vector& operator=(const physx::PxVec3& v);
operator physx::PxVec3() const;

_forceinline Vector& operator+=(const Vector &v)
{
x+=v.x; y+=v.y; z += v.z;
Expand Down Expand Up @@ -255,8 +258,6 @@ class Vector // same data-layout as engine's vec3_t,
inline float Length(void) const { return sqrt( x*x + y*y + z*z ); }
inline float LengthSqr(void) const { return (x*x + y*y + z*z); }
inline float MaxCoord() const { return Q_max(x, Q_max(y, z)); }
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
operator const float *() const { return &x; }

inline Vector Normalize() const
{
Expand Down Expand Up @@ -437,7 +438,7 @@ class Radian
inline Radian operator*(float fl) const { return Radian(x*fl, y*fl, z*fl); }
inline Radian operator/(float fl) const { return Radian(x/fl, y/fl, z/fl); }
inline Radian operator*(const Radian& v) const { return Radian(x*v.x, y*v.y, z*v.z); }
const Radian& operator=(const NxVec3& v);
const Radian& operator=(const physx::PxVec3& v);

_forceinline Radian& operator+=(const Radian &v)
{
Expand Down
39 changes: 33 additions & 6 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ list(APPEND SVDLL_SOURCES
"multiplay_gamerules.cpp"
"monsters/nihilanth.cpp"
"monsters/nodes.cpp"
"novodex.cpp"
"physics/NxUserStream.cpp"
"monsters/osprey.cpp"
"pathcorner.cpp"
"physents.cpp"
Expand Down Expand Up @@ -138,11 +136,22 @@ list(APPEND SVDLL_SOURCES
"monsters/zombie.cpp"
)

if(ENABLE_PHYSX)
list(APPEND SVDLL_SOURCES
"novodex.cpp"
"physics/contact_report.cpp"
"physics/debug_renderer.cpp"
"physics/triangulated_shape.cpp"
"physics/NxUserStream.cpp"
"physics/NxErrorStream.cpp"
)
endif()

# add .def file to sources
if(MSVC)
list(APPEND SVDLL_SOURCES
"server.def"
)
list(APPEND SVDLL_SOURCES
"server.def"
)
endif()

add_library (${PROJECT_NAME} SHARED ${SVDLL_SOURCES})
Expand All @@ -151,13 +160,21 @@ target_include_directories(${PROJECT_NAME} PRIVATE
"monsters"
"physics"
"wpn_shared"
"${CMAKE_SOURCE_DIR}/external/novodex"
"${CMAKE_SOURCE_DIR}/external/physx/physx/include"
"${CMAKE_SOURCE_DIR}/external/physx/physx/include/cooking"
"${CMAKE_SOURCE_DIR}/external/physx/physx/include/geometry"
"${CMAKE_SOURCE_DIR}/external/physx/pxshared/include"
"${CMAKE_SOURCE_DIR}/external/physx/pxshared/include/foundation"
"${CMAKE_SOURCE_DIR}/common"
"${CMAKE_SOURCE_DIR}/engine"
"${CMAKE_SOURCE_DIR}/game_shared"
"${CMAKE_SOURCE_DIR}/public"
)

target_link_directories(${PROJECT_NAME} PRIVATE
"${CMAKE_SOURCE_DIR}/external/physx/bin/win.x86_64.vc142.mt/debug"
)

if(HAVE_TGMATH_H)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_TGMATH_H=1)
endif()
Expand Down Expand Up @@ -199,6 +216,16 @@ if(ENABLE_STATIC_LINKING)
set_compiler_runtime(${PROJECT_NAME} STATIC)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE
PhysX_64
PhysXCommon_64
PhysXCooking_64
PhysXExtensions_static_64
PhysXFoundation_64
PhysXPvdSDK_static_64
PhysXVehicle_static_64
)

set_target_properties (${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
Expand Down
5 changes: 4 additions & 1 deletion server/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,10 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity )
DEFINE_FIELD( m_iActorType, FIELD_CHARACTER ),
DEFINE_FIELD( m_iActorFlags, FIELD_INTEGER ),
DEFINE_FIELD( m_iBodyFlags, FIELD_INTEGER ),
DEFINE_FIELD( m_usActorGroup, FIELD_SHORT ),
DEFINE_FIELD( m_iFilterData[0], FIELD_INTEGER ),
DEFINE_FIELD( m_iFilterData[1], FIELD_INTEGER ),
DEFINE_FIELD( m_iFilterData[2], FIELD_INTEGER ),
DEFINE_FIELD( m_iFilterData[3], FIELD_INTEGER ),
DEFINE_FIELD( m_flBodyMass, FIELD_FLOAT ),
DEFINE_FIELD( m_fFreezed, FIELD_BOOLEAN ),
END_DATADESC()
Expand Down
10 changes: 5 additions & 5 deletions server/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ CBaseEntity
CBasePlayer
CBaseGroup
*/

#define MAX_PATH_SIZE 10 // max number of nodes available for a path.
#pragma once
#define MAX_PATH_SIZE 10 // max number of nodes available for a path.

// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions)
#define FCAP_SET_MOVEDIR 0x00000001 // convert initial angles into direction (doors used)
Expand Down Expand Up @@ -242,9 +242,9 @@ class CBaseEntity

// PhysX description
unsigned char m_iActorType; // static, kinetic or dynamic
int m_iActorFlags; // NxActor->flags
int m_iBodyFlags; // NxBodyDesc->flags
short m_usActorGroup; // NxActor->group
uint32_t m_iActorFlags; // NxActor->flags
uint32_t m_iBodyFlags; // NxBodyDesc->flags
uint32_t m_iFilterData[4]; // NxActor->group
float m_flBodyMass; // NxActor->mass
BOOL m_fFreezed; // is body sleeps?
bool m_isChaining;
Expand Down
Loading

0 comments on commit 106efa2

Please sign in to comment.