From c527b228615b6afa16fb3a7ebbe1b9827677f56f Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Sat, 22 Aug 2009 21:37:18 +0000 Subject: [PATCH] Support for left-handed weapons --- reaction/code/cgame/cg_draw.c | 2 +- reaction/code/cgame/cg_local.h | 2 +- reaction/code/cgame/cg_main.c | 4 ++-- reaction/code/cgame/cg_weapons.c | 4 +--- reaction/code/renderer/tr_local.h | 1 + reaction/code/renderer/tr_scene.c | 4 ++++ reaction/code/renderer/tr_surface.c | 17 +++++++++++++++-- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/reaction/code/cgame/cg_draw.c b/reaction/code/cgame/cg_draw.c index 13f5b9c6..7543314c 100644 --- a/reaction/code/cgame/cg_draw.c +++ b/reaction/code/cgame/cg_draw.c @@ -509,7 +509,7 @@ static void CG_DrawStatusBar(void) static float hcolors[3][4] = { {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 1.0f}, - {1.0f, 0.0f, 0.0f, 1.0f} + {0.8f, 0.0f, 0.0f, 1.0f} }; cent = &cg_entities[cg.snap->ps.clientNum]; diff --git a/reaction/code/cgame/cg_local.h b/reaction/code/cgame/cg_local.h index a850b663..0d6ba6ca 100644 --- a/reaction/code/cgame/cg_local.h +++ b/reaction/code/cgame/cg_local.h @@ -1949,7 +1949,7 @@ extern vmCvar_t cg_RQ3_strobe; extern vmCvar_t cg_RQ3_predictWeapons; //Makro - left-handed weapons -//extern vmCvar_t cg_RQ3_leftHanded; +extern vmCvar_t cg_RQ3_leftHanded; //Makro - sun flares extern vmCvar_t cg_RQ3_flareIntensity; //Makro - ssg crosshair size diff --git a/reaction/code/cgame/cg_main.c b/reaction/code/cgame/cg_main.c index 65a8113d..4d6087fb 100644 --- a/reaction/code/cgame/cg_main.c +++ b/reaction/code/cgame/cg_main.c @@ -628,7 +628,7 @@ vmCvar_t cg_RQ3_predictWeapons; //Makro - left-handed models -//vmCvar_t cg_RQ3_leftHanded; +vmCvar_t cg_RQ3_leftHanded; //Makro - dev tools /* @@ -919,7 +919,7 @@ static cvarTable_t cvarTable[] = { // bk001129 {&cg_oldPlasma, "cg_oldPlasma", "1", CVAR_ARCHIVE}, {&cg_trueLightning, "cg_trueLightning", "0.0", CVAR_ARCHIVE}, //Makro - left-handed weapons - //{&cg_RQ3_leftHanded, "cg_RQ3_leftHanded", "0", CVAR_ARCHIVE}, + {&cg_RQ3_leftHanded, "cg_RQ3_leftHanded", "0", CVAR_ARCHIVE}, //Makro - dev tool /* {&cg_RQ3_angle0, "cg_RQ3_angle0", "0", 0}, diff --git a/reaction/code/cgame/cg_weapons.c b/reaction/code/cgame/cg_weapons.c index 0f42c716..800f1532 100644 --- a/reaction/code/cgame/cg_weapons.c +++ b/reaction/code/cgame/cg_weapons.c @@ -1781,13 +1781,11 @@ void CG_AddViewWeapon(playerState_t * ps) hand.backlerp = 0; hand.hModel = weapon->handsModel; hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT; - /* - hand.nonNormalizedAxes = qtrue; + if (cg_RQ3_leftHanded.integer) { VectorNegate(hand.axis[1], hand.axis[1]); } - */ // add everything onto the hand CG_AddPlayerWeapon(&hand, ps, &cg.predictedPlayerEntity, ps->persistant[PERS_TEAM]); diff --git a/reaction/code/renderer/tr_local.h b/reaction/code/renderer/tr_local.h index 3abcfbea..0f42457d 100644 --- a/reaction/code/renderer/tr_local.h +++ b/reaction/code/renderer/tr_local.h @@ -76,6 +76,7 @@ typedef struct { qboolean needDlights; // true for bmodels that touch a dlight qboolean lightingCalculated; + qboolean mirrored; // mirrored matrix, needs reversed culling vec3_t lightDir; // normalized direction towards light vec3_t ambientLight; // color normalized to 0-255 int ambientLightInt; // 32 bit rgba packed diff --git a/reaction/code/renderer/tr_scene.c b/reaction/code/renderer/tr_scene.c index db1fdeb5..7a4a6e3a 100644 --- a/reaction/code/renderer/tr_scene.c +++ b/reaction/code/renderer/tr_scene.c @@ -207,6 +207,7 @@ RE_AddRefEntityToScene ===================== */ void RE_AddRefEntityToScene( const refEntity_t *ent ) { + vec3_t cross; if ( !tr.registered ) { return; } @@ -219,6 +220,9 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { backEndData[tr.smpFrame]->entities[r_numentities].e = *ent; backEndData[tr.smpFrame]->entities[r_numentities].lightingCalculated = qfalse; + + CrossProduct(ent->axis[0], ent->axis[1], cross); + backEndData[tr.smpFrame]->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); r_numentities++; } diff --git a/reaction/code/renderer/tr_surface.c b/reaction/code/renderer/tr_surface.c index 13655697..18bef9e3 100644 --- a/reaction/code/renderer/tr_surface.c +++ b/reaction/code/renderer/tr_surface.c @@ -879,8 +879,21 @@ static void RB_SurfaceMesh(md3Surface_t *surface) { indexes = surface->numTriangles * 3; Bob = tess.numIndexes; Doug = tess.numVertexes; - for (j = 0 ; j < indexes ; j++) { - tess.indexes[Bob + j] = Doug + triangles[j]; + + if (backEnd.currentEntity->mirrored) { + // Makro - this should be done differently, but since we're copying + // indices in a loop anyway (see below), reversing them in the same loop + // is practically free... + + for (j = 0 ; j < indexes ; j += 3) { + tess.indexes[Bob + j + 0] = Doug + triangles[j + 0]; + tess.indexes[Bob + j + 1] = Doug + triangles[j + 2]; + tess.indexes[Bob + j + 2] = Doug + triangles[j + 1]; + } + } else { + for (j = 0 ; j < indexes ; j++) { + tess.indexes[Bob + j] = Doug + triangles[j]; + } } tess.numIndexes += indexes;