diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2009-10-03 13:10:33 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:32 +0000 |
commit | 3fd952a2fc79839dc2443e86a5bd5b9200db69fe (patch) | |
tree | d340aecb61ded55793ce90e24ef2a26b3911cc75 | |
parent | 1f2000da1ab287833af69689ddefb9fbf92039cb (diff) |
* Cleanup thirdperson spec code
- Remove the temporary manual override cvars
- Bring back cg_thirdpersonangle by request even though it's only useful in non-gameplay cases
- Move thirdperson view offset values to classconfigs where they belong
- Attempt once again to fix cg_thirdpersonpitchfollow
-rw-r--r-- | assets/configs/classes/builder.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/builderupg.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/human_base.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/human_bsuit.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level0.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level1.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level1upg.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level2.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level2upg.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level3.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level3upg.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/level4.cfg | 1 | ||||
-rw-r--r-- | assets/configs/classes/spectator.cfg | 1 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 5 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 10 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 103 | ||||
-rw-r--r-- | src/game/bg_misc.c | 73 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 |
18 files changed, 81 insertions, 124 deletions
diff --git a/assets/configs/classes/builder.cfg b/assets/configs/classes/builder.cfg index d06fec6f..dd1d6651 100644 --- a/assets/configs/classes/builder.cfg +++ b/assets/configs/classes/builder.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 0 crouchViewheight 0 +shoulderOffsets -8 15 13 diff --git a/assets/configs/classes/builderupg.cfg b/assets/configs/classes/builderupg.cfg index feb0e61c..e1b73fc3 100644 --- a/assets/configs/classes/builderupg.cfg +++ b/assets/configs/classes/builderupg.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 0 crouchViewheight 0 +shoulderOffsets -8 15 13 diff --git a/assets/configs/classes/human_base.cfg b/assets/configs/classes/human_base.cfg index 2c22a08b..6749bad1 100644 --- a/assets/configs/classes/human_base.cfg +++ b/assets/configs/classes/human_base.cfg @@ -14,3 +14,4 @@ zOffset -2.0 viewheight 24 crouchViewheight 7 +shoulderOffsets -10 15 0 diff --git a/assets/configs/classes/human_bsuit.cfg b/assets/configs/classes/human_bsuit.cfg index c5928835..0cdca1e7 100644 --- a/assets/configs/classes/human_bsuit.cfg +++ b/assets/configs/classes/human_bsuit.cfg @@ -14,3 +14,4 @@ zOffset -16.0 viewheight 29
crouchViewheight 29
+shoulderOffsets -30 25 -2
diff --git a/assets/configs/classes/level0.cfg b/assets/configs/classes/level0.cfg index c064c421..62f1b586 100644 --- a/assets/configs/classes/level0.cfg +++ b/assets/configs/classes/level0.cfg @@ -14,3 +14,4 @@ zOffset -2.0 viewheight 0
crouchViewheight 0
+shoulderOffsets -5 0 17
diff --git a/assets/configs/classes/level1.cfg b/assets/configs/classes/level1.cfg index 81daae31..3add57e0 100644 --- a/assets/configs/classes/level1.cfg +++ b/assets/configs/classes/level1.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 0
crouchViewheight 0
+shoulderOffsets -10 0 18
diff --git a/assets/configs/classes/level1upg.cfg b/assets/configs/classes/level1upg.cfg index 9448694a..28a4bebb 100644 --- a/assets/configs/classes/level1upg.cfg +++ b/assets/configs/classes/level1upg.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 0
crouchViewheight 0
+shoulderOffsets -10 0 18
diff --git a/assets/configs/classes/level2.cfg b/assets/configs/classes/level2.cfg index 2f0fea3d..999f9b52 100644 --- a/assets/configs/classes/level2.cfg +++ b/assets/configs/classes/level2.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 8
crouchViewheight 8
+shoulderOffsets 0 12 5
diff --git a/assets/configs/classes/level2upg.cfg b/assets/configs/classes/level2upg.cfg index 7c559987..5ea674ce 100644 --- a/assets/configs/classes/level2upg.cfg +++ b/assets/configs/classes/level2upg.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 10
crouchViewheight 10
+shoulderOffsets 0 12 5
diff --git a/assets/configs/classes/level3.cfg b/assets/configs/classes/level3.cfg index 100b4c16..60732018 100644 --- a/assets/configs/classes/level3.cfg +++ b/assets/configs/classes/level3.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 24
crouchViewheight 24
+shoulderOffsets -10 15 8
diff --git a/assets/configs/classes/level3upg.cfg b/assets/configs/classes/level3upg.cfg index aa0cfe65..e0e74555 100644 --- a/assets/configs/classes/level3upg.cfg +++ b/assets/configs/classes/level3upg.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 27
crouchViewheight 27
+shoulderOffsets -10 17 12
diff --git a/assets/configs/classes/level4.cfg b/assets/configs/classes/level4.cfg index adb65e07..ad8482e0 100644 --- a/assets/configs/classes/level4.cfg +++ b/assets/configs/classes/level4.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 64 crouchViewheight 64 +shoulderOffsets -20 -25 30 diff --git a/assets/configs/classes/spectator.cfg b/assets/configs/classes/spectator.cfg index f7efc1f3..eeec60c1 100644 --- a/assets/configs/classes/spectator.cfg +++ b/assets/configs/classes/spectator.cfg @@ -14,3 +14,4 @@ zOffset 0.0 viewheight 0 crouchViewheight 0 +shoulderOffsets 0 0 0 diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index c1e5dada..68895d72 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1475,13 +1475,10 @@ extern vmCvar_t cg_tracerWidth; extern vmCvar_t cg_tracerLength; extern vmCvar_t cg_autoswitch; extern vmCvar_t cg_thirdPerson; +extern vmCvar_t cg_thirdPersonAngle; extern vmCvar_t cg_thirdPersonShoulderViewMode; extern vmCvar_t cg_thirdPersonPitchFollow; extern vmCvar_t cg_thirdPersonRange; -extern vmCvar_t cg_shoulderViewOverride; -extern vmCvar_t cg_shoulderViewUp; -extern vmCvar_t cg_shoulderViewRight; -extern vmCvar_t cg_shoulderViewForward; extern vmCvar_t cg_stereoSeparation; extern vmCvar_t cg_lagometer; extern vmCvar_t cg_synchronousClients; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 44edf153..3fa458d1 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -141,13 +141,10 @@ vmCvar_t cg_tracerWidth; vmCvar_t cg_tracerLength; vmCvar_t cg_autoswitch; vmCvar_t cg_thirdPerson; +vmCvar_t cg_thirdPersonAngle; vmCvar_t cg_thirdPersonShoulderViewMode; vmCvar_t cg_thirdPersonPitchFollow; vmCvar_t cg_thirdPersonRange; -vmCvar_t cg_shoulderViewOverride; -vmCvar_t cg_shoulderViewUp; -vmCvar_t cg_shoulderViewRight; -vmCvar_t cg_shoulderViewForward; vmCvar_t cg_stereoSeparation; vmCvar_t cg_lagometer; vmCvar_t cg_synchronousClients; @@ -268,12 +265,9 @@ static cvarTable_t cvarTable[ ] = { &cg_tracerLength, "cg_tracerlength", "100", CVAR_CHEAT }, { &cg_thirdPersonRange, "cg_thirdPersonRange", "75", CVAR_ARCHIVE }, { &cg_thirdPerson, "cg_thirdPerson", "0", CVAR_CHEAT }, + { &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT }, { &cg_thirdPersonPitchFollow, "cg_thirdPersonPitchFollow", "0", 0 }, { &cg_thirdPersonShoulderViewMode, "cg_thirdPersonShoulderViewMode", "1", CVAR_ARCHIVE }, - { &cg_shoulderViewOverride, "cg_shoulderViewOverride", "0", 0 }, - { &cg_shoulderViewUp, "cg_shoulderViewUp", "0", 0 }, - { &cg_shoulderViewRight, "cg_shoulderViewRight", "0", 0 }, - { &cg_shoulderViewForward, "cg_shoulderViewForward", "0", 0 }, { &cg_stats, "cg_stats", "0", 0 }, { &cg_drawFriend, "cg_drawFriend", "1", CVAR_ARCHIVE }, { &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE }, diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 964fa705..06f621f5 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -402,6 +402,8 @@ void CG_OffsetThirdPersonView( void ) } } + rotationAngles[ YAW ] -= cg_thirdPersonAngle.value; + // Move the camera range distance back. AngleVectors( rotationAngles, forward, right, up ); VectorCopy( cg.refdef.vieworg, view ); @@ -449,87 +451,26 @@ CG_OffsetShoulderView */ void CG_OffsetShoulderView( void ) { - int i; - int cmdNum; - usercmd_t cmd, oldCmd; - vec3_t rotationAngles; - vec3_t axis[ 3 ], rotaxis[ 3 ]; - float deltaMousePitch; - static float mousePitch; - vec3_t forward, right, up; - float classFwdOffset = 0.0f, classUpOffset = 0.0f, classRightOffset = 0.0f; + int i; + int cmdNum; + usercmd_t cmd, oldCmd; + vec3_t rotationAngles; + vec3_t axis[ 3 ], rotaxis[ 3 ]; + float deltaMousePitch; + static float mousePitch; + vec3_t forward, right, up; + classConfig_t* classConfig; + + // Ignore following pitch; it's too jerky otherwise. + if( !cg_thirdPersonPitchFollow.integer ) + cg.refdefViewAngles[ PITCH ] = 0.0f; AngleVectors( cg.refdefViewAngles, forward, right, up ); - // Set a nice view by offsetting from vieworigin to get to the "shoulder" - // for each class. - // FIXME: These need to not be hard-coded so hackishly - switch( cg.snap->ps.stats[ STAT_CLASS ] ) - { - case PCL_ALIEN_BUILDER0: - case PCL_ALIEN_BUILDER0_UPG: - classFwdOffset = -8.0f; - classRightOffset = 15.0f; - classUpOffset = 13.0f; - break; - case PCL_ALIEN_LEVEL0: - classFwdOffset = -5.0f; - classRightOffset = 0.0f; - classUpOffset = 17.0f; - break; - case PCL_ALIEN_LEVEL1: - case PCL_ALIEN_LEVEL1_UPG: - classFwdOffset = -10.0f; - classRightOffset = 0.0f; - classUpOffset = 18.0f; - break; - case PCL_ALIEN_LEVEL2: - case PCL_ALIEN_LEVEL2_UPG: - classFwdOffset = 0.0f; - classRightOffset = 12.0f; - classUpOffset = 5.0f; - break; - case PCL_ALIEN_LEVEL3: - classFwdOffset = -10.0f; - classRightOffset = 15.0f; - classUpOffset = 8.0f; - break; - case PCL_ALIEN_LEVEL3_UPG: - classFwdOffset = -10.0f; - classRightOffset = 17.0f; - classUpOffset = 12.0f; - break; - case PCL_ALIEN_LEVEL4: - classFwdOffset = -20.0f; - classRightOffset = -25.0f; - classUpOffset = 30.0f; - break; - case PCL_HUMAN: - classFwdOffset = -10.0f; - classRightOffset = 15.0f; - classUpOffset = 0.0f; - break; - case PCL_HUMAN_BSUIT: - classFwdOffset = -30.0f; - classRightOffset = 25.0f; - classUpOffset = -2.0f; - break; - } - - // The override is temporary so that people can help find good offset positions for me. - // It will not remain in final code. - if( !cg_shoulderViewOverride.integer ) - { - VectorMA( cg.refdef.vieworg, classFwdOffset, forward, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, classUpOffset, up, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, classRightOffset, right, cg.refdef.vieworg ); - } - else - { - VectorMA( cg.refdef.vieworg, cg_shoulderViewForward.value, forward, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, cg_shoulderViewUp.value, up, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, cg_shoulderViewRight.value, right, cg.refdef.vieworg ); - } + classConfig = BG_ClassConfig( cg.snap->ps.stats[ STAT_CLASS ] ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 0 ], forward, cg.refdef.vieworg ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 1 ], right, cg.refdef.vieworg ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 2 ], up, cg.refdef.vieworg ); // If someone is playing like this, the rest is already taken care of // so just get the firstperson effects and leave. @@ -554,11 +495,7 @@ void CG_OffsetShoulderView( void ) // Handle pitch. rotationAngles[ PITCH ] = mousePitch; - // Ignore following pitch; it's too jerky otherwise. - if( cg_thirdPersonPitchFollow.integer ) - mousePitch += cg.refdefViewAngles[ PITCH ]; - - rotationAngles[ PITCH ] = AngleNormalize180( rotationAngles[ PITCH ] ); + rotationAngles[ PITCH ] = AngleNormalize180( rotationAngles[ PITCH ] + AngleNormalize180( cg.refdefViewAngles[ PITCH ] ) ); if( rotationAngles [ PITCH ] < -90.0f ) rotationAngles [ PITCH ] = -90.0f; if( rotationAngles [ PITCH ] > 90.0f ) rotationAngles [ PITCH ] = 90.0f; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 5adbcd33..f41e07b5 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1440,20 +1440,21 @@ static qboolean BG_ParseClassFile( const char *filename, classConfig_t *cc ) int defined = 0; enum { - MODEL = 1 << 0, - SKIN = 1 << 1, - HUD = 1 << 2, - MODELSCALE = 1 << 3, - SHADOWSCALE = 1 << 4, - MINS = 1 << 5, - MAXS = 1 << 6, - DEADMINS = 1 << 7, - DEADMAXS = 1 << 8, - CROUCHMAXS = 1 << 9, - VIEWHEIGHT = 1 << 10, - CVIEWHEIGHT = 1 << 11, - ZOFFSET = 1 << 12, - NAME = 1 << 13 + MODEL = 1 << 0, + SKIN = 1 << 1, + HUD = 1 << 2, + MODELSCALE = 1 << 3, + SHADOWSCALE = 1 << 4, + MINS = 1 << 5, + MAXS = 1 << 6, + DEADMINS = 1 << 7, + DEADMAXS = 1 << 8, + CROUCHMAXS = 1 << 9, + VIEWHEIGHT = 1 << 10, + CVIEWHEIGHT = 1 << 11, + ZOFFSET = 1 << 12, + NAME = 1 << 13, + SHOULDEROFFSETS = 1 << 14 }; // load the file @@ -1662,27 +1663,41 @@ static qboolean BG_ParseClassFile( const char *filename, classConfig_t *cc ) defined |= NAME; continue; } + else if( !Q_stricmp( token, "shoulderOffsets" ) ) + { + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( &text_p ); + if( !token ) + break; + + cc->shoulderOffsets[ i ] = atof( token ); + } + defined |= SHOULDEROFFSETS; + continue; + } Com_Printf( S_COLOR_RED "ERROR: unknown token '%s'\n", token ); return qfalse; } - if( !( defined & MODEL ) ) token = "model"; - else if( !( defined & SKIN ) ) token = "skin"; - else if( !( defined & HUD ) ) token = "hud"; - else if( !( defined & MODELSCALE ) ) token = "modelScale"; - else if( !( defined & SHADOWSCALE ) ) token = "shadowScale"; - else if( !( defined & MINS ) ) token = "mins"; - else if( !( defined & MAXS ) ) token = "maxs"; - else if( !( defined & DEADMINS ) ) token = "deadMins"; - else if( !( defined & DEADMAXS ) ) token = "deadMaxs"; - else if( !( defined & CROUCHMAXS ) ) token = "crouchMaxs"; - else if( !( defined & VIEWHEIGHT ) ) token = "viewheight"; - else if( !( defined & CVIEWHEIGHT ) ) token = "crouchViewheight"; - else if( !( defined & ZOFFSET ) ) token = "zOffset"; - else if( !( defined & NAME ) ) token = "name"; - else token = ""; + if( !( defined & MODEL ) ) token = "model"; + else if( !( defined & SKIN ) ) token = "skin"; + else if( !( defined & HUD ) ) token = "hud"; + else if( !( defined & MODELSCALE ) ) token = "modelScale"; + else if( !( defined & SHADOWSCALE ) ) token = "shadowScale"; + else if( !( defined & MINS ) ) token = "mins"; + else if( !( defined & MAXS ) ) token = "maxs"; + else if( !( defined & DEADMINS ) ) token = "deadMins"; + else if( !( defined & DEADMAXS ) ) token = "deadMaxs"; + else if( !( defined & CROUCHMAXS ) ) token = "crouchMaxs"; + else if( !( defined & VIEWHEIGHT ) ) token = "viewheight"; + else if( !( defined & CVIEWHEIGHT ) ) token = "crouchViewheight"; + else if( !( defined & ZOFFSET ) ) token = "zOffset"; + else if( !( defined & NAME ) ) token = "name"; + else if( !( defined & SHOULDEROFFSETS ) ) token = "shoulderOffsets"; + else token = ""; if( strlen( token ) > 0 ) { diff --git a/src/game/bg_public.h b/src/game/bg_public.h index e1654ef8..1b9c3e2f 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -965,6 +965,7 @@ typedef struct int viewheight; int crouchViewheight; float zOffset; + vec3_t shoulderOffsets; } classConfig_t; //stages |