Skip to content

Commit 5968902

Browse files
committed
Merge branch 'master' into for-0.56.0/sync
2 parents c6ca193 + 0cc7809 commit 5968902

File tree

10 files changed

+310
-164
lines changed

10 files changed

+310
-164
lines changed

CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,15 @@ if(NOT DAEMON_EXTERNAL_APP)
141141

142142
set(NACL_RUNTIME_PATH "" CACHE STRING "Directory containing the NaCl binaries")
143143

144-
# Not supported on mac because the included version is too old
145-
if(APPLE)
146-
set(USE_CURSES OFF)
147-
elseif(WIN32)
144+
if (WIN32)
145+
# The alternative code is based on non-curses unix terminal functions.
148146
set(USE_CURSES ON)
149147
else()
148+
if (NOT APPLE)
149+
# Not supported on macOS because the included version is too old.
150+
option(USE_CURSES_NCURSES "Use ncurses instead of PDCursesMod" ON)
151+
endif()
152+
150153
option(USE_CURSES "Enable fancy colors in terminal's output" ON)
151154
endif()
152155

@@ -657,20 +660,24 @@ endif()
657660
# Curses, pdcurses on Windows and ncursesw on Unix
658661
if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP)
659662
if (USE_CURSES)
660-
if (WIN32)
661-
set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} gdi32 comdlg32)
663+
if (USE_CURSES_NCURSES)
664+
# Tells FindCurses that ncurses is required.
665+
set(CURSES_NEED_NCURSES 1)
666+
667+
add_definitions(-DUSE_CURSES -DUSE_CURSES_NCURSES)
668+
find_package(CursesW REQUIRED)
669+
set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} ${CURSESW_LIBRARIES})
670+
include_directories(${CURSESW_INCLUDE_DIR})
671+
else ()
672+
if (WIN32)
673+
set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} gdi32 comdlg32)
674+
endif()
662675

663676
add_definitions(-DPDC_WIDE -DPDC_FORCE_UTF8 -DPDC_RGB -DUSE_CURSES)
664677
add_library(srclibs-pdcurses EXCLUDE_FROM_ALL ${PDCURSESLIST})
665678
set_target_properties(srclibs-pdcurses PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
666679
set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} srclibs-pdcurses)
667680
include_directories(${LIB_DIR}/pdcursesmod)
668-
else ()
669-
add_definitions(-DUSE_CURSES)
670-
set(CURSES_NEED_NCURSES 1) # Tells FindCurses that ncurses is required
671-
find_package(CursesW REQUIRED)
672-
set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} ${CURSESW_LIBRARIES})
673-
include_directories(${CURSESW_INCLUDE_DIR})
674681
endif()
675682
endif()
676683
endif()

src.cmake

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ if (DAEMON_PARENT_SCOPE_DIR)
8686
set(COMMONLIST ${COMMONLIST} PARENT_SCOPE)
8787
endif()
8888

89+
# Tests for code shared by engine and gamelogic
90+
set(COMMONTESTLIST
91+
${LIB_DIR}/tinyformat/TinyformatTest.cpp
92+
${COMMON_DIR}/ColorTest.cpp
93+
${COMMON_DIR}/FileSystemTest.cpp
94+
${COMMON_DIR}/StringTest.cpp
95+
${COMMON_DIR}/cm/unittest.cpp
96+
${COMMON_DIR}/MathTest.cpp
97+
${COMMON_DIR}/UtilTest.cpp
98+
${ENGINE_DIR}/qcommon/q_math_test.cpp
99+
)
100+
89101
set(RENDERERLIST
90102
${ENGINE_DIR}/renderer/DetectGLVendors.cpp
91103
${ENGINE_DIR}/renderer/DetectGLVendors.h
@@ -279,15 +291,8 @@ else()
279291
)
280292
endif()
281293

282-
# Tests for engine-lib
283-
set(ENGINETESTLIST
284-
${LIB_DIR}/tinyformat/TinyformatTest.cpp
285-
${COMMON_DIR}/ColorTest.cpp
286-
${COMMON_DIR}/FileSystemTest.cpp
287-
${COMMON_DIR}/StringTest.cpp
288-
${COMMON_DIR}/cm/unittest.cpp
289-
${COMMON_DIR}/MathTest.cpp
290-
${COMMON_DIR}/UtilTest.cpp
294+
# Tests runnable for any engine variant
295+
set(ENGINETESTLIST ${COMMONTESTLIST}
291296
${ENGINE_DIR}/framework/CommandSystemTest.cpp
292297
)
293298

src/engine/qcommon/q_math.cpp

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,39 +3199,19 @@ void TransInit( transform_t *t )
31993199
t->scale = 1.0f;
32003200
}
32013201

3202-
// copy a transform
3203-
void TransCopy( const transform_t *in, transform_t *out )
3204-
{
3205-
memcpy( out, in, sizeof( transform_t ) );
3206-
}
3207-
32083202
// apply a transform to a point
32093203
void TransformPoint( const transform_t *t, const vec3_t in, vec3_t out )
32103204
{
32113205
QuatTransformVector( t->rot, in, out );
32123206
VectorScale( out, t->scale, out );
32133207
VectorAdd( out, t->trans, out );
32143208
}
3215-
// apply the inverse of a transform to a point
3216-
void TransformPointInverse( const transform_t *t, const vec3_t in, vec3_t out )
3217-
{
3218-
VectorSubtract( in, t->trans, out );
3219-
VectorScale( out, 1.0f / t->scale, out );
3220-
QuatTransformVectorInverse( t->rot, out, out );
3221-
}
32223209

32233210
// apply a transform to a normal vector (ignore scale and translation)
32243211
void TransformNormalVector( const transform_t *t, const vec3_t in, vec3_t out )
32253212
{
32263213
QuatTransformVector( t->rot, in, out );
32273214
}
3228-
// apply the inverse of a transform to a normal vector (ignore scale
3229-
// and translation)
3230-
void TransformNormalVectorInverse( const transform_t *t, const vec3_t in,
3231-
vec3_t out )
3232-
{
3233-
QuatTransformVectorInverse( t->rot, in, out );
3234-
}
32353215

32363216
// initialize a transform with a pure rotation
32373217
void TransInitRotationQuat( const quat_t quat, transform_t *t )
@@ -3240,16 +3220,6 @@ void TransInitRotationQuat( const quat_t quat, transform_t *t )
32403220
VectorClear( t->trans );
32413221
t->scale = 1.0f;
32423222
}
3243-
void TransInitRotation( const vec3_t axis, float angle, transform_t *t )
3244-
{
3245-
float sa = sinf( 0.5f * angle );
3246-
float ca = cosf( 0.5f * angle );
3247-
quat_t q;
3248-
3249-
VectorScale( axis, sa, q );
3250-
q[3] = ca;
3251-
TransInitRotationQuat( q, t );
3252-
}
32533223
// initialize a transform with a pure translation
32543224
void TransInitTranslation( const vec3_t vec, transform_t *t )
32553225
{
@@ -3292,16 +3262,6 @@ void TransAddRotationQuat( const quat_t quat, transform_t *t )
32923262
QuatMultiply2( tmp, t->rot );
32933263
QuatCopy( tmp, t->rot );
32943264
}
3295-
void TransAddRotation( const vec3_t axis, float angle, transform_t *t )
3296-
{
3297-
float sa = sinf( 0.5f * angle );
3298-
float ca = cosf( 0.5f * angle );
3299-
quat_t q;
3300-
3301-
VectorScale( axis, sa, q );
3302-
q[3] = ca;
3303-
TransAddRotationQuat( q, t );
3304-
}
33053265

33063266
// add a scale to the start of an existing transform
33073267
void TransInsScale( float factor, transform_t *t )
@@ -3319,9 +3279,9 @@ void TransAddScale( float factor, transform_t *t )
33193279
void TransInsTranslation( const vec3_t vec, transform_t *t )
33203280
{
33213281
vec3_t tmp;
3322-
3323-
TransformPoint( t, vec, tmp );
3324-
VectorAdd( t->trans, tmp, t->trans );
3282+
QuatTransformVector( t->rot, vec, tmp );
3283+
VectorScale( tmp, t->scale, tmp );
3284+
VectorAdd( tmp, t->trans, t->trans );
33253285
}
33263286

33273287
// add a translation at the end of an existing transformation
@@ -3334,7 +3294,7 @@ void TransAddTranslation( const vec3_t vec, transform_t *t )
33343294
void TransCombine( const transform_t *a, const transform_t *b,
33353295
transform_t *out )
33363296
{
3337-
TransCopy( a, out );
3297+
*out = *a;
33383298

33393299
TransAddRotationQuat( b->rot, out );
33403300
TransAddScale( b->scale, out );
@@ -3345,15 +3305,15 @@ void TransCombine( const transform_t *a, const transform_t *b,
33453305
void TransInverse( const transform_t *in, transform_t *out )
33463306
{
33473307
quat_t inverse;
3348-
static transform_t tmp; // static for proper alignment in QVMs
3308+
transform_t tmp;
33493309

33503310
TransInit( &tmp );
33513311
VectorNegate( in->trans, tmp.trans );
33523312
TransAddScale( 1.0f / in->scale, &tmp );
33533313
QuatCopy( in->rot, inverse );
33543314
QuatInverse( inverse );
33553315
TransAddRotationQuat( inverse, &tmp );
3356-
TransCopy( &tmp, out );
3316+
*out = tmp;
33573317
}
33583318

33593319
// lerp between transforms

0 commit comments

Comments
 (0)