Skip to content

Commit

Permalink
Some Missing Dhewm3 1.5.2 i forgot to add
Browse files Browse the repository at this point in the history
  • Loading branch information
FriskTheFallenHuman committed Nov 29, 2024
1 parent 498eb0e commit f8ef1f4
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 86 deletions.
4 changes: 2 additions & 2 deletions neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@ set(src_game
game/Player.cpp
game/PlayerIcon.cpp
game/PlayerView.cpp
game/Projectile.cpp
game/projectile.cpp
game/Pvs.cpp
game/SecurityCamera.cpp
game/SmokeParticles.cpp
game/Sound.cpp
game/Target.cpp
game/Trigger.cpp
game/trigger.cpp
game/Weapon.cpp
game/WorldSpawn.cpp
game/ai/AAS.cpp
Expand Down
4 changes: 3 additions & 1 deletion neo/framework/UsercmdGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ typedef enum {
UB_BUTTON6,
UB_BUTTON7,

UB_ATTACK,
UB_ATTACK, // NOTE: this value (20) is hardcoded in idUserInterfaceLocal::HandleEvent() !
UB_SPEED,
UB_ZOOM,
UB_SHOWSCORES,
Expand Down Expand Up @@ -965,6 +965,8 @@ void idUsercmdGenLocal::Key( int keyNum, bool down ) {

int action = idKeyInput::GetUsercmdAction( keyNum );

// TODO: if action == 0 return ?

if ( down ) {

buttonState[ action ]++;
Expand Down
184 changes: 114 additions & 70 deletions neo/renderer/Model_hhBeam.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/

#include "precompiled.h"
#pragma hdrstop

Expand All @@ -6,66 +34,76 @@

// Simple beam model. different with idRenderModelBeam, the line's start point is not view origin.

static idCVar harm_r_skipHHBeam("harm_r_skipHHBeam", "0", CVAR_RENDERER | CVAR_BOOL, "[Harmattan]: Skip beam model render");
static const struct viewDef_s *current_view; // temp, should as a parameter

void hhRenderModelBeam::InitFromFile( const char *fileName )
{
/*
====================
hhRenderModelBeam::InitFromFile
====================
*/
void hhRenderModelBeam::InitFromFile( const char *fileName ) {
name = fileName;
declBeam = static_cast<const hhDeclBeam *>(declManager->FindType(DECL_BEAM, fileName));
declBeam = static_cast<const hhDeclBeam *>( declManager->FindType( DECL_BEAM, fileName ) );
}

void hhRenderModelBeam::LoadModel()
{
/*
====================
hhRenderModelBeam::LoadModel
====================
*/
void hhRenderModelBeam::LoadModel( void ) {
idRenderModelStatic::LoadModel();
}

dynamicModel_t hhRenderModelBeam::IsDynamicModel() const
{
/*
====================
hhRenderModelBeam::IsDynamicModel
====================
*/
dynamicModel_t hhRenderModelBeam::IsDynamicModel( void ) const {
return DM_CONTINUOUS; // regenerate for every view
}

idRenderModel* hhRenderModelBeam::InstantiateDynamicModel( const struct renderEntity_s *renderEntity, const struct viewDef_s *view, idRenderModel *cachedModel )
{
/*
====================
hhRenderModelBeam::InstantiateDynamicModel
====================
*/
idRenderModel *hhRenderModelBeam::InstantiateDynamicModel( const struct renderEntity_s *renderEntity, const struct viewDef_s *view, idRenderModel *cachedModel ) {
idRenderModelStatic *staticModel;
srfTriangles_t *tri;
modelSurface_t surf;

if (cachedModel) {
if ( cachedModel ) {
delete cachedModel;
cachedModel = NULL;
}

if (renderEntity == NULL || view == NULL) {
if ( renderEntity == NULL || view == NULL ) {
delete cachedModel;
return NULL;
}

if(harm_r_skipHHBeam.GetBool())
return NULL;

if(!declBeam || !renderEntity->beamNodes || declBeam->numNodes < 2)
if ( !declBeam || !renderEntity->beamNodes || declBeam->numNodes < 2 ) {
return NULL;
}

if (cachedModel != NULL) {

assert(dynamic_cast<idRenderModelStatic *>(cachedModel) != NULL);
if ( cachedModel != NULL ) {

staticModel = static_cast<idRenderModelStatic *>(cachedModel);
assert( dynamic_cast<idRenderModelStatic *>( cachedModel ) != NULL );
staticModel = static_cast<idRenderModelStatic *>( cachedModel );
} else {

staticModel = new idRenderModelStatic;
int id = 0;

// line
for(int i = 0; i < declBeam->numBeams; i++)
{
for( int i = 0; i < declBeam->numBeams; i++ ) {
int vertNum = declBeam->numNodes - 1;
tri = R_AllocStaticTriSurf();
R_AllocStaticTriSurfVerts(tri, 4 * vertNum);
R_AllocStaticTriSurfIndexes(tri, 6 * vertNum);
R_AllocStaticTriSurfVerts( tri, 4 * vertNum );
R_AllocStaticTriSurfIndexes( tri, 6 * vertNum );

for(int m = 0; m < vertNum; m++)
{
for( int m = 0; m < vertNum; m++ ) {
tri->verts[4 * m + 0].Clear();
tri->verts[4 * m + 0].st[0] = 0;
tri->verts[4 * m + 0].st[1] = 0;
Expand Down Expand Up @@ -114,20 +152,20 @@ idRenderModel* hhRenderModelBeam::InstantiateDynamicModel( const struct renderEn
// surf.shader = tr.defaultMaterial;
surf.shader = declBeam->shader[i];

staticModel->AddSurface(surf);
staticModel->AddSurface( surf );
}

// quad
for(int i = 0; i < declBeam->numBeams; i++)
{
for(int m = 0; m < 2; m++)
{
if(!declBeam->quadShader[i][m]) // no material
for( int i = 0; i < declBeam->numBeams; i++ ) {
for( int m = 0; m < 2; m++ ) {
// no material
if( !declBeam->quadShader[i][m] ) {
continue;
}

tri = R_AllocStaticTriSurf();
R_AllocStaticTriSurfVerts(tri, 4);
R_AllocStaticTriSurfIndexes(tri, 6);
R_AllocStaticTriSurfVerts( tri, 4 );
R_AllocStaticTriSurfIndexes( tri, 6 );

tri->verts[0].Clear();
tri->verts[0].st[0] = 0;
Expand Down Expand Up @@ -176,52 +214,53 @@ idRenderModel* hhRenderModelBeam::InstantiateDynamicModel( const struct renderEn
// surf.shader = tr.defaultMaterial;
surf.shader = declBeam->quadShader[i][m];

staticModel->AddSurface(surf);
staticModel->AddSurface( surf );
}
}
}

current_view = view; // should as a parameter
int id = 0;
for(int i = 0; i < declBeam->numBeams; i++)
{
UpdateSurface(renderEntity, i, renderEntity->beamNodes, const_cast<modelSurface_t *>(staticModel->Surface(i)));
for( int i = 0; i < declBeam->numBeams; i++ ) {
UpdateSurface( renderEntity, i, renderEntity->beamNodes, const_cast<modelSurface_t *>( staticModel->Surface( i ) ) );
id++;
}
for(int i = 0; i < declBeam->numBeams; i++)
{
for(int m = 0; m < 2; m++)
{
if(!declBeam->quadShader[i][m])
for( int i = 0; i < declBeam->numBeams; i++ ) {
for( int m = 0; m < 2; m++ ) {
if( !declBeam->quadShader[i][m] ) {
continue;
UpdateQuadSurface(renderEntity, i, m, renderEntity->beamNodes, const_cast<modelSurface_t *>(staticModel->Surface(id++)));
}

UpdateQuadSurface( renderEntity, i, m, renderEntity->beamNodes, const_cast<modelSurface_t *>( staticModel->Surface( id++ ) ) );
}
}

staticModel->bounds = Bounds(renderEntity);
staticModel->bounds = Bounds( renderEntity );

//LOGI("BOUND %s %s %s", Name(), staticModel->bounds[0].ToString(), staticModel->bounds[1].ToString())
return staticModel;
}

idBounds hhRenderModelBeam::Bounds( const struct renderEntity_s *renderEntity ) const
{
/*
====================
hhRenderModelBeam::Bounds
====================
*/
idBounds hhRenderModelBeam::Bounds( const struct renderEntity_s *renderEntity ) const {
idBounds b;

b.Zero();

if (!renderEntity || !renderEntity->beamNodes) {
b.ExpandSelf(8.0f);
if ( !renderEntity || !renderEntity->beamNodes ) {
b.ExpandSelf( 8.0f );
} else {
for(int i = 0; i < declBeam->numBeams; i++)
{
for(int m = 0; m < declBeam->numNodes; m++)
{
for( int i = 0; i < declBeam->numBeams; i++ ) {
for( int m = 0; m < declBeam->numNodes; m++ ) {
const idVec3 &target = renderEntity->beamNodes->nodes[m];
idBounds tb;
tb.Zero();
tb.AddPoint(target);
tb.ExpandSelf(declBeam->thickness[i] * 0.5);
tb.AddPoint( target );
tb.ExpandSelf( declBeam->thickness[i] * 0.5 );
b += tb;
}
}
Expand All @@ -230,15 +269,18 @@ idBounds hhRenderModelBeam::Bounds( const struct renderEntity_s *renderEntity )
return b;
}

void hhRenderModelBeam::UpdateSurface( const struct renderEntity_s *renderEntity, const int index, const hhBeamNodes_t *beam, modelSurface_t *surf )
{
/*
====================
hhRenderModelBeam::UpdateSurface
====================
*/
void hhRenderModelBeam::UpdateSurface( const struct renderEntity_s *renderEntity, const int index, const hhBeamNodes_t *beam, modelSurface_t *surf ) {
srfTriangles_t *tri = surf->geometry;
idVec3 up;
renderEntity->axis.ProjectVector(current_view->renderView.viewaxis[2], up);
renderEntity->axis.ProjectVector( current_view->renderView.viewaxis[2], up );

int numLines = declBeam->numNodes - 1;
for(int i = 0; i < numLines; i++)
{
for( int i = 0; i < numLines; i++ ) {
const idVec3 &start = beam->nodes[i];
const idVec3 &target = beam->nodes[i + 1];

Expand All @@ -250,16 +292,20 @@ void hhRenderModelBeam::UpdateSurface( const struct renderEntity_s *renderEntity
tri->verts[4 * i + 3].xyz = target + minor;
}

R_BoundTriSurf(tri);
R_BoundTriSurf( tri );
}

void hhRenderModelBeam::UpdateQuadSurface( const struct renderEntity_s *renderEntity, const int index, int quadIndex, const hhBeamNodes_t *beam, modelSurface_t *surf )
{
/*
====================
hhRenderModelBeam::UpdateQuadSurface
====================
*/
void hhRenderModelBeam::UpdateQuadSurface( const struct renderEntity_s *renderEntity, const int index, int quadIndex, const hhBeamNodes_t *beam, modelSurface_t *surf ) {
srfTriangles_t *tri = surf->geometry;
idVec3 up;
idVec3 right;
renderEntity->axis.ProjectVector(current_view->renderView.viewaxis[2], up);
renderEntity->axis.ProjectVector(current_view->renderView.viewaxis[1], right);
renderEntity->axis.ProjectVector( current_view->renderView.viewaxis[2], up );
renderEntity->axis.ProjectVector( current_view->renderView.viewaxis[1], right );
idVec3 target = quadIndex == 0 ? beam->nodes[0] : beam->nodes[declBeam->numNodes - 1];

idVec3 upw = up * declBeam->quadSize[index][quadIndex] * 0.5f;
Expand All @@ -270,7 +316,5 @@ void hhRenderModelBeam::UpdateQuadSurface( const struct renderEntity_s *renderEn
tri->verts[2].xyz = target + rightw - upw;
tri->verts[3].xyz = target + rightw + upw;

R_BoundTriSurf(tri);
}


R_BoundTriSurf( tri );
}
4 changes: 2 additions & 2 deletions neo/renderer/Model_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class idRenderModelStatic : public idRenderModel {
bool LoadLWO( const char *fileName );
bool LoadFLT( const char *fileName );
// HUMANHEAD mdc - added support for precomputed models
bool LoadPPM( const char *fileName ) {}
bool WritePPM( const char *fileName ) {}
bool LoadPPM( const char *fileName ) { return false; }
bool WritePPM( const char *fileName ) { return false; }
void DeletePPM( const char *fileName ) {}
// HUMANHEAD END

Expand Down
12 changes: 6 additions & 6 deletions neo/renderer/draw_arb2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void RB_ARB2_DrawInteraction( const drawInteraction_t *din ) {
float parm[4];
parm[0] = parm[1] = parm[2] = r_brightness.GetFloat();
parm[3] = 1.0/r_gamma.GetFloat(); // 1.0/gamma so the shader doesn't have to do this calculation
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 4, parm );
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, PP_GAMMA_BRIGHTNESS, parm );
}

// set the textures
Expand Down Expand Up @@ -459,7 +459,7 @@ void R_LoadARBProgram( int progIndex ) {
// note that strlen("dhewm3tmpres") == strlen("result.color")
const char* tmpres = "TEMP dhewm3tmpres; # injected by dhewm3 for gamma correction\n";

// Note: program.env[4].xyz = r_brightness; program.env[4].w = 1.0/r_gamma
// Note: program.env[21].xyz = r_brightness; program.env[21].w = 1.0/r_gamma
// outColor.rgb = pow(dhewm3tmpres.rgb*r_brightness, vec3(1.0/r_gamma))
// outColor.a = dhewm3tmpres.a;
const char* extraLines =
Expand All @@ -468,10 +468,10 @@ void R_LoadARBProgram( int progIndex ) {
// POW might not work with a negative base (it looks wrong with intel's Linux driver)
// and clamping values >1 to 1 is ok because when writing to result.color
// it's clamped anyway and pow(base, exp) is always >= 1 for base >= 1
"MUL_SAT dhewm3tmpres.xyz, program.env[4], dhewm3tmpres;\n" // first multiply with brightness
"POW result.color.x, dhewm3tmpres.x, program.env[4].w;\n" // then do pow(dhewm3tmpres.xyz, vec3(1/gamma))
"POW result.color.y, dhewm3tmpres.y, program.env[4].w;\n" // (apparently POW only supports scalars, not whole vectors)
"POW result.color.z, dhewm3tmpres.z, program.env[4].w;\n"
"MUL_SAT dhewm3tmpres.xyz, program.env[21], dhewm3tmpres;\n" // first multiply with brightness
"POW result.color.x, dhewm3tmpres.x, program.env[21].w;\n" // then do pow(dhewm3tmpres.xyz, vec3(1/gamma))
"POW result.color.y, dhewm3tmpres.y, program.env[21].w;\n" // (apparently POW only supports scalars, not whole vectors)
"POW result.color.z, dhewm3tmpres.z, program.env[21].w;\n"
"MOV result.color.w, dhewm3tmpres.w;\n" // alpha remains unmodified
"\nEND\n\n"; // we add this block right at the end, replacing the original "END" string

Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/draw_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void RB_SetProgramEnvironment( bool isPostProcess ) {
// (setting them to 1.0 makes them no-ops)
parm[0] = parm[1] = parm[2] = parm[3] = 1.0f;
}
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 4, parm );
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, PP_GAMMA_BRIGHTNESS, parm );
}

//
Expand Down
1 change: 1 addition & 0 deletions neo/renderer/tr_guisurf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/

#include "precompiled.h"
#pragma hdrstop

Expand Down
Loading

0 comments on commit f8ef1f4

Please sign in to comment.