Fix up statically linking the ODE plugin into the engine (eukara wanted me to fix this up).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6243 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-05-28 17:58:53 +00:00
parent 4d8015d9cf
commit c45b0e5cf8
7 changed files with 101 additions and 52 deletions

View file

@ -855,6 +855,38 @@ ELSE()
ENDIF()
ENDIF()
#ODE Physics library plugin
SET(FTE_PLUG_ODE true CACHE STRING "Compile ODE rigid body physics plugin.")
SET_PROPERTY(CACHE FTE_PLUG_ODE PROPERTY STRINGS false true static)
IF(FTE_PLUG_ODE)
FIND_PATH(LIBODE_INCLUDE_DIR ode/ode.h)
IF (LIBODE_INCLUDE_DIR)
FIND_LIBRARY(LIBODE_LIBRARY ode)
ENDIF()
IF (LIBODE_LIBRARY)
IF (FTE_PLUG_ODE STREQUAL "static")
#SET (FTE_COMMON_FILES ${FTE_COMMON_FILES} engine/common/com_phys_ode.c)
SET(FTE_LIB_DEFINES "${FTE_LIB_DEFINES};USE_INTERNAL_ODE;ODE_STATIC")
SET(FTE_LIBS ${FTE_LIBS} ${LIBODE_LIBRARY})
SET(FTESV_LIBS ${FTE_LIBS} ${LIBODE_LIBRARY})
SET(FTE_INCLUDES ${FTE_INCLUDES} ${ODE_INCLUDE_DIRS})
ELSE()
ADD_LIBRARY(plug_ode MODULE
plugins/plugin.c
engine/common/com_phys_ode.c
engine/common/mathlib.c
)
TARGET_INCLUDE_DIRECTORIES(plug_ode PUBLIC ${ODE_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(plug_ode PROPERTIES COMPILE_DEFINITIONS "FTEPLUGIN;ODE_STATIC")
TARGET_LINK_LIBRARIES(plug_ode ${SYS_LIBS} ${LIBODE_LIBRARY})
EMBED_PLUGIN_META(ode "ODE Physics" "Provides Rigid Body Physics behaviours.")
ENDIF()
ELSE()
MESSAGE(WARNING "ODE library not found, no ode plugin for you")
ENDIF()
ENDIF()
IF(ANDROID)
#android sucks. everything is a library. so we build the engine as a shared library and completely ignore dedicated servers+tools
SET(FTE_ENGINE_FTEDROID true CACHE BOOL "Compile ftedroid engine shared library.")
@ -865,6 +897,7 @@ IF(ANDROID)
${FTE_CLIENT_FILES}
)
SET_TARGET_PROPERTIES(ftedroid PROPERTIES COMPILE_DEFINITIONS "${FTE_LIB_DEFINES};${FTE_DEFINES};${FTE_REVISON}")
TARGET_INCLUDE_DIRECTORIES(ftedroid PUBLIC ${FTE_INCLUDES})
TARGET_LINK_LIBRARIES(ftedroid ${FTE_LIBS} )
SET(INSTALLTARGS ${INSTALLTARGS} ftedroid)
ENDIF()
@ -879,6 +912,7 @@ ELSE()
${FTE_SERVER_FILES}
)
SET_TARGET_PROPERTIES(fteqw PROPERTIES COMPILE_DEFINITIONS "${FTE_LIB_DEFINES};${FTE_DEFINES};${FTE_REVISON}")
TARGET_INCLUDE_DIRECTORIES(fteqw PUBLIC ${FTE_INCLUDES})
TARGET_LINK_LIBRARIES(fteqw ${FTE_LIBS})
SET(INSTALLTARGS ${INSTALLTARGS} fteqw)
ENDIF()
@ -891,6 +925,7 @@ ELSE()
${FTE_SERVER_FILES}
)
SET_TARGET_PROPERTIES(fteqw-sv PROPERTIES COMPILE_DEFINITIONS "SERVERONLY;${FTE_LIB_DEFINES};${FTESV_DEFINES};${FTE_REVISON}")
TARGET_INCLUDE_DIRECTORIES(fteqw-sv PUBLIC ${FTE_INCLUDES})
TARGET_LINK_LIBRARIES(fteqw-sv ${FTESV_LIBS})
SET(INSTALLTARGS ${INSTALLTARGS} fteqw-sv)
ENDIF()
@ -903,6 +938,7 @@ ELSE()
${FTE_CLIENT_FILES}
)
SET_TARGET_PROPERTIES(fteqw-cl PROPERTIES COMPILE_DEFINITIONS "CLIENTONLY;${FTE_LIB_DEFINES};${FTE_DEFINES};${FTE_REVISON}")
TARGET_INCLUDE_DIRECTORIES(fteqw-cl PUBLIC ${FTE_INCLUDES})
TARGET_LINK_LIBRARIES(fteqw-cl ${FTE_LIBS})
SET(INSTALLTARGS ${INSTALLTARGS} fteqw-cl)
ENDIF()
@ -1179,29 +1215,6 @@ ENDIF()
# ENDIF()
#ENDIF()
#ODE Physics library plugin
SET(FTE_PLUG_ODE true CACHE BOOL "Compile ODE rigid body physics plugin.")
IF(FTE_PLUG_ODE)
FIND_PATH(LIBODE_INCLUDE_DIR ode/ode.h)
IF (LIBODE_INCLUDE_DIR)
FIND_LIBRARY(LIBODE_LIBRARY ode)
ENDIF()
IF (LIBODE_LIBRARY)
ADD_LIBRARY(plug_ode MODULE
plugins/plugin.c
engine/common/com_phys_ode.c
engine/common/mathlib.c
)
TARGET_INCLUDE_DIRECTORIES(plug_ode PUBLIC ${ODE_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(plug_ode PROPERTIES COMPILE_DEFINITIONS "FTEPLUGIN;ODE_STATIC")
TARGET_LINK_LIBRARIES(plug_ode ${SYS_LIBS} ${LIBODE_LIBRARY})
EMBED_PLUGIN_META(ode "ODE Physics" "Provides Rigid Body Physics behaviours.")
ELSE()
MESSAGE(WARNING "ODE library not found, no ode plugin for you")
ENDIF()
ENDIF()
#EzQuake Hud port plugin
SET(FTE_PLUG_EZHUD true CACHE BOOL "Compile MoreQuakeWorld Hud plugin .")
IF(FTE_PLUG_EZHUD)

View file

@ -123,7 +123,7 @@ endif
FTE_CONFIG?=fteqw
ifneq ($(findstring msvc,$(FTE_TARGET)),msvc)
ifeq (,$(FTE_CONFIG_EXTRA))
export FTE_CONFIG_EXTRA := $(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS common/config_$(FTE_CONFIG).h)
export FTE_CONFIG_EXTRA := $(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS $(CFLAGS) common/config_$(FTE_CONFIG).h)
endif
endif
BRANDFLAGS+=-DCONFIG_FILE_NAME=config_$(FTE_CONFIG).h $(FTE_CONFIG_EXTRA)
@ -156,8 +156,13 @@ ifneq (,$(findstring -Os,$(FTE_CONFIG_EXTRA)))
CPUOPTIMIZATIONS+=-Os
BRANDFLAGS:=$(filter-out -O%,$(BRANDFLAGS))
endif
ifneq (,$(findstring DLINK_ODE,$(FTE_CONFIG_EXTRA)))
#ode library will be statically linked.
LINK_ODE=1
endif
ifneq (,$(findstring DLINK_INTERNAL_BULLET,$(FTE_CONFIG_EXTRA)))
INTERNAL_BULLET=1 #bullet plugin will be built into the exe itself
#bullet plugin will be built into the exe itself
INTERNAL_BULLET=1
endif
ifeq ($(BITS),64)
@ -1040,6 +1045,10 @@ ifeq (1,$(LINK_ZLIB))
CLIENTLIBFLAGS+=-DZLIB_STATIC
CLIENTLDDEPS+=-lz
endif
ifeq (1,$(LINK_ODE))
ALL_CFLAGS+=$(shell $(PKGCONFIG) ode --cflags --silence-errors) -DODE_STATIC
COMMONLDDEPS+=$(shell $(PKGCONFIG) ode --libs --silence-errors)
endif
ifeq (1,$(strip $(INTERNAL_BULLET)))
COMMON_OBJS+=com_phys_bullet.o
ALL_CFLAGS+=-I/usr/include/bullet -I$(ARCHLIBS)/bullet3-$(BULLETVER)/src

View file

@ -726,8 +726,15 @@ extern cvar_t gl_playermip;
extern cvar_t r_lightmap_saturation;
#ifdef FTEPLUGIN //evil hack... boo hiss.
extern cvar_t *cvar_r_meshpitch;
extern cvar_t *cvar_r_meshroll;
#define r_meshpitch (*cvar_r_meshpitch)
#define r_meshroll (*cvar_r_meshroll)
#else
extern cvar_t r_meshpitch;
extern cvar_t r_meshroll; //gah!
#endif
extern cvar_t vid_hardwaregamma;
enum {

View file

@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//if we're not building as an fte-specific plugin, we must be being built as part of the fte engine itself.
//(no, we don't want to act as a plugin for ezquake...)
#ifndef FTEPLUGIN
#define FTEENGINE
#define FTEPLUGIN
#define Plug_Init Plug_ODE_Init
#endif
@ -60,11 +59,11 @@ static int VectorCompare (const vec3_t v1, const vec3_t v2)
return 1;
}
cvar_t *cvar_r_meshpitch;
cvar_t *cvar_r_meshroll;
#endif
static rbeplugfuncs_t *rbefuncs;
cvar_t r_meshpitch;
cvar_t r_meshroll;
//============================================================================
// physics engine support
@ -88,6 +87,9 @@ cvar_t r_meshroll;
#define dDOUBLE
#include "ode/ode.h"
#else
#ifndef ODE_DYNAMIC
#define ODE_DYNAMIC
#endif
#ifdef WINAPI
// ODE does not use WINAPI
#define ODE_API VARGS /*vargs because fte likes to be compiled fastcall (vargs is defined as cdecl...)*/
@ -736,6 +738,11 @@ dGeomID (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, d
//int (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
//void (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
typedef void dMessageFunction (int errnum, const char *msg, va_list ap);
void (ODE_API *dSetErrorHandler) (dMessageFunction *fn);
void (ODE_API *dSetDebugHandler) (dMessageFunction *fn);
void (ODE_API *dSetMessageHandler) (dMessageFunction *fn);
static dllfunction_t odefuncs[] =
{
// {"dGetConfiguration", (void **) &dGetConfiguration},
@ -1182,6 +1189,10 @@ static dllfunction_t odefuncs[] =
// {"dGeomTriMeshGetPoint", (void **) &dGeomTriMeshGetPoint},
// {"dGeomTriMeshGetTriangleCount", (void **) &dGeomTriMeshGetTriangleCount},
// {"dGeomTriMeshDataUpdate", (void **) &dGeomTriMeshDataUpdate},
{(void **) &dSetErrorHandler, "dSetErrorHandler"},
{(void **) &dSetDebugHandler, "dSetDebugHandler"},
{(void **) &dSetMessageHandler, "dSetMessageHandler"},
{NULL, NULL}
};
@ -1241,14 +1252,14 @@ static void World_ODE_RunCmd(world_t *world, rbecommandqueue_t *cmd);
#define vsnprintf(s,l,f,a) _vsnprintf(s,l,f,a);string[sizeof(string)-1] = 0;
#endif
void MyODEErrorHandler (int errnum, const char *msg, va_list ap)
static void MyODEErrorHandler (int errnum, const char *msg, va_list ap)
{
char string[1024];
vsnprintf (string,sizeof(string), msg, ap);
string[sizeof(string)-1] = 0;
Sys_Errorf("ODE ERROR %i: %s", errnum, string);
Sys_Error("ODE ERROR %i: %s", errnum, string);
}
void MyODEMessageHandler (int errnum, const char *msg, va_list ap)
static void MyODEMessageHandler (int errnum, const char *msg, va_list ap)
{
char string[1024];
vsnprintf (string,sizeof(string), msg, ap);
@ -1299,7 +1310,7 @@ static qboolean World_ODE_Init(void)
#ifdef ODE_DYNAMIC
// Load the DLL
ode_dll = pSys_LoadLibrary(dllname, odefuncs);
ode_dll = plugfuncs->LoadDLL(dllname, odefuncs);
if (ode_dll)
#endif
{
@ -1317,7 +1328,7 @@ static qboolean World_ODE_Init(void)
# else
Con_Printf("ode library not compiled for double precision - incompatible! Not using ODE physics.\n");
# endif
pSys_CloseLibrary(ode_dll);
plugfuncs->CloseDLL(ode_dll);
ode_dll = NULL;
}
#endif
@ -1326,6 +1337,7 @@ static qboolean World_ODE_Init(void)
#ifdef ODE_DYNAMIC
if (!ode_dll)
{
Con_Printf("ODE plugin failed: \"%s\" library missing.\n", dllname);
return false;
}
#endif
@ -1344,7 +1356,7 @@ static void World_ODE_Shutdown(void)
{
dCloseODE();
#ifdef ODE_DYNAMIC
pSys_CloseLibrary(ode_dll);
plugfuncs->CloseDLL(ode_dll);
ode_dll = NULL;
#endif
}
@ -2265,7 +2277,7 @@ static void World_ODE_Frame_BodyFromEntity(world_t *world, wedict_t *ed)
dMassSetCylinderTotal(&mass, massval, axisindex+1, radius, length);
break;
default:
Sys_Errorf("World_ODE_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
Sys_Error("World_ODE_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
}
Matrix3x4_InvertTo4x4_Simple(ed->rbe.offsetmatrix, ed->rbe.offsetimatrix);
ed->rbe.massbuf = BZ_Malloc(sizeof(dMass));
@ -2738,8 +2750,10 @@ static void QDECL World_ODE_Start(world_t *world)
memset(ctx, 0, sizeof(*ctx));
world->rbe = &ctx->pub;
#ifndef FTEENGINE
r_meshpitch.value = cvarfuncs->GetFloat("r_meshpitch");
r_meshroll.value = cvarfuncs->GetFloat("r_meshroll");
#endif
VectorAvg(world->worldmodel->mins, world->worldmodel->maxs, center);
VectorSubtract(world->worldmodel->maxs, center, extents);
@ -2831,12 +2845,11 @@ static void QDECL Plug_ODE_Shutdown(void)
qboolean Plug_Init(void)
{
#ifndef ODE_STATIC
CHECKBUILTIN(Sys_LoadLibrary);
CHECKBUILTIN(Sys_CloseLibrary);
#endif
rbefuncs = plugfuncs->GetEngineInterface("RBE", sizeof(*rbefuncs));
#ifndef FTEENGINE
cvar_r_meshpitch = cvarfuncs->GetNVFDG("r_meshpitch", "1", 0, NULL, NULL);
cvar_r_meshroll = cvarfuncs->GetNVFDG("r_meshroll", "1", 0, NULL, NULL);
#endif
if (rbefuncs && ( rbefuncs->version < RBEPLUGFUNCS_VERSION ||
rbefuncs->wedictsize != sizeof(wedict_t)))
rbefuncs = NULL;
@ -2845,13 +2858,6 @@ qboolean Plug_Init(void)
Con_Printf("ODE plugin failed: Engine is incompatible.\n");
return false;
}
#ifndef ODE_STATIC
if (!BUILTINISVALID(Sys_LoadLibrary) || !BUILTINISVALID(Sys_CloseLibrary))
{
Con_Printf("ODE plugin failed: Engine too old.\n");
return false;
}
#endif
if (!rbefuncs || !rbefuncs->RegisterPhysicsEngine)
Con_Printf("ODE plugin failed: Engine doesn't support physics engine plugins.\n");
@ -2861,7 +2867,6 @@ qboolean Plug_Init(void)
{
if (!World_ODE_Init())
{
Con_Printf("ODE plugin failed: ODE library missing.\n");
rbefuncs->UnregisterPhysicsEngine("ODE");
return false;
}

View file

@ -221,5 +221,9 @@
//enable some staticaly linked libraries
-DLINK_FREETYPE //international text requires international fonts.
#if defined(USE_INTERNAL_ODE) && !defined(ODE_DYNAMIC)
-DLINK_ODE
#endif
//-Os //optimise for size instead of speed. less cpu cache needed means that its sometimes faster anyway.
#endif

View file

@ -14,17 +14,24 @@ static struct plugin_s *q3plug;
#ifdef PLUGINS
#define Q_snprintf Q_snprintfz
#define Q_strlcpy Q_strncpyz
#define Q_strlcat Q_strncatz
#define Sys_Errorf Sys_Error
#ifdef MODELFMT_GLTF
#define Q_snprintf Q_snprintfz
#define Q_strlcpy Q_strncpyz
#define Q_strlcat Q_strncatz
#include "../plugins/models/gltf.c"
#endif
#ifdef USE_INTERNAL_ODE
#include "../engine/common/com_phys_ode.c"
#endif
cvar_t plug_sbar = CVARD("plug_sbar", "3", "Controls whether plugins are allowed to draw the hud, rather than the engine (when allowed by csqc). This is typically used to permit the ezhud plugin without needing to bother unloading it.\n=0: never use hud plugins.\n&1: Use hud plugins in deathmatch.\n&2: Use hud plugins in singleplayer/coop.\n=3: Always use hud plugins (when loaded).");
cvar_t plug_loaddefault = CVARD("plug_loaddefault", "1", "0: Load plugins only via explicit plug_load commands\n1: Load built-in plugins and those selected via the package manager\n2: Scan for misc plugins, loading all that can be found, but not built-ins.\n3: Scan for plugins, and then load any built-ins");
qboolean Plug_Q3_Init(void);
extern qboolean Plug_Q3_Init(void);
extern qboolean Plug_Bullet_Init(void);
extern qboolean Plug_ODE_Init(void);
static struct
{
const char *name;

View file

@ -1,6 +1,9 @@
#ifndef PR_COMMON_H
#define PR_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#include "progtype.h"
#include "progslib.h"
@ -1173,3 +1176,4 @@ enum
#ifdef __cplusplus
};
#endif
#endif