summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2017-04-13 11:30:00 +0000
committer/dev/humancontroller <devhc@example.com>2017-04-15 17:24:18 +0200
commitf38f646bfc1b9b3904359b92cbd16377cd618308 (patch)
treee54e182859e6552d0de5fc0b5520d87cf79d8179 /src
parente6bbd69de4cf8a316c9e17d882b1386a1e4da3fc (diff)
add a BG function to get the view origin of a client
for this, import BG_GetClientNormal()
Diffstat (limited to 'src')
-rw-r--r--src/game/bg_misc.c34
-rw-r--r--src/game/bg_public.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index b7f23f3..3fdec70 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -5173,6 +5173,40 @@ qboolean BG_RotateAxis( vec3_t surfNormal, vec3_t inAxis[ 3 ],
/*
===============
+BG_GetClientNormal
+
+Get the normal for the surface the client is walking on
+===============
+*/
+void BG_GetClientNormal( const playerState_t *ps, vec3_t normal )
+{
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
+ {
+ if( ps->eFlags & EF_WALLCLIMBCEILING )
+ VectorSet( normal, 0.0f, 0.0f, -1.0f );
+ else
+ VectorCopy( ps->grapplePoint, normal );
+ }
+ else
+ VectorSet( normal, 0.0f, 0.0f, 1.0f );
+}
+
+/*
+===============
+BG_GetClientViewOrigin
+
+Get the position of the client's eye, based on the client's position, the surface's normal, and client's view height
+===============
+*/
+void BG_GetClientViewOrigin( const playerState_t *ps, vec3_t viewOrigin )
+{
+ vec3_t normal;
+ BG_GetClientNormal( ps, normal );
+ VectorMA( ps->origin, ps->viewheight, normal, viewOrigin );
+}
+
+/*
+===============
BG_PositionBuildableRelativeToPlayer
Find a place to build a buildable
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index cbb2def..1a5b81c 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1121,6 +1121,8 @@ void BG_DeactivateUpgrade( int item, int stats[ ] );
qboolean BG_UpgradeIsActive( int item, int stats[ ] );
qboolean BG_RotateAxis( vec3_t surfNormal, vec3_t inAxis[ 3 ],
vec3_t outAxis[ 3 ], qboolean inverse, qboolean ceiling );
+void BG_GetClientNormal( const playerState_t *ps, vec3_t normal );
+void BG_GetClientViewOrigin( const playerState_t *ps, vec3_t viewOrigin );
void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps,
const vec3_t mins, const vec3_t maxs,
void (*trace)( trace_t *, const vec3_t, const vec3_t,