Skip to content

Commit

Permalink
More work.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed Apr 28, 2024
1 parent 318c4b2 commit d4560ca
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 51 deletions.
35 changes: 28 additions & 7 deletions model/newstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,28 @@ static float Fog_distance, Fog_eye_distance;
static vector Fog_view_pos, Specular_view_pos, Bump_view_pos;
static matrix Unscaled_bumpmap_matrix;

static int ModelFaceSortFunc(const short *a, const short *b) {
static int ModelFaceSortFunc(const short *a, const short *b);

static inline void RenderSubmodelFace(poly_model *pm, bsp_info *sm, int facenum);
static inline void RenderSubmodelLightmapFace(poly_model *pm, bsp_info *sm, int facenum);
static inline void RenderSubmodelFaceFogged(poly_model *pm, bsp_info *sm, int facenum);
static inline void RenderSubmodelFaceSpecular(poly_model *pm, bsp_info *sm, int facenum);

/// Draws a glowing cone of light.
static void DrawGlowEffect(vector *pos, float r, float g, float b, vector *norm, float size);

/// Draws a glowing cone of light that represents thrusters
static void DrawThrusterEffect(vector *pos, float r, float g, float b, vector *norm, float size, float length);

static void RenderSubmodelFacesSorted(poly_model *pm, bsp_info *sm);
static void RenderSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm);

/// Rotates all of the points of a submodel, plus supplies color info.
static void RotateModelPoints(poly_model *pm, bsp_info *sm);

static float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bool f_use_all_frames);

int ModelFaceSortFunc(const short *a, const short *b) {
float az, bz;

az = face_depth[*a];
Expand All @@ -128,7 +149,7 @@ static int ModelFaceSortFunc(const short *a, const short *b) {
}

#ifdef _DEBUG
void model_draw_outline(int nverts, g3Point **pointlist) {
static void model_draw_outline(int nverts, g3Point **pointlist) {
int i;

for (i = 0; i < nverts - 1; i++)
Expand All @@ -137,7 +158,7 @@ void model_draw_outline(int nverts, g3Point **pointlist) {
g3_DrawLine(GR_RGB(255, 255, 255), pointlist[i], pointlist[0]);
}

void DrawSubmodelFaceOutline(int nv, g3Point **pointlist) {
static void DrawSubmodelFaceOutline(int nv, g3Point **pointlist) {
int i;
g3Point tpnt[64];
g3Point *tpnt_list[64];
Expand All @@ -160,7 +181,7 @@ int Lightmap_debug_subnum = -1;
int Lightmap_debug_facenum = -1;
int Lightmap_debug_model = -1;

static inline void RenderSubmodelFace(poly_model *pm, bsp_info *sm, int facenum) {
inline void RenderSubmodelFace(poly_model *pm, bsp_info *sm, int facenum) {

g3Point *pointlist[100];
int bm_handle;
Expand Down Expand Up @@ -463,7 +484,7 @@ static inline void RenderSubmodelFace(poly_model *pm, bsp_info *sm, int facenum)
#endif
}

static inline void RenderSubmodelLightmapFace(poly_model *pm, bsp_info *sm, int facenum) {
inline void RenderSubmodelLightmapFace(poly_model *pm, bsp_info *sm, int facenum) {
g3Point *pointlist[100];

polyface *fp = &sm->faces[facenum];
Expand Down Expand Up @@ -497,7 +518,7 @@ static inline void RenderSubmodelLightmapFace(poly_model *pm, bsp_info *sm, int
g3_SetTriangulationTest(0);
}

static inline void RenderSubmodelFaceFogged(poly_model *pm, bsp_info *sm, int facenum) {
inline void RenderSubmodelFaceFogged(poly_model *pm, bsp_info *sm, int facenum) {
g3Point *pointlist[100];
polyface *fp = &sm->faces[facenum];
int modelnum = sm - pm->submodel;
Expand Down Expand Up @@ -548,7 +569,7 @@ static inline void RenderSubmodelFaceFogged(poly_model *pm, bsp_info *sm, int fa
g3_SetTriangulationTest(0);
}

static inline void RenderSubmodelFaceSpecular(poly_model *pm, bsp_info *sm, int facenum) {
inline void RenderSubmodelFaceSpecular(poly_model *pm, bsp_info *sm, int facenum) {
g3Point *pointlist[100];
polyface *fp = &sm->faces[facenum];
int modelnum = sm - pm->submodel;
Expand Down
68 changes: 46 additions & 22 deletions model/polymodel.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* $Logfile: /DescentIII/Main/model/polymodel.cpp $
Expand Down Expand Up @@ -658,6 +658,27 @@ lightmap_object *Polylighting_lightmap_object;
vector *Polymodel_light_direction, Polymodel_fog_plane, Polymodel_specular_pos, Polymodel_fog_portal_vert,
Polymodel_bump_pos;

static inline void RecursiveAssignWB(poly_model *pm, int sm_index, int wb_index);
static void FindWBSubobjects(poly_model *pm);
/// Sets aside a polymodel for use.
/// Errors and returns -1 if none free.
static int AllocPolyModel();
static void ReadModelVector(vector *vec, CFILE *infile);
static void ReadModelStringLen(char *ptr, int len, CFILE *infile);
/// Given a modelnumber, opens the original pof file and attempts to rematch that
/// models textures with the bitmaps with have in memory.
static int ReloadModelTextures(int modelnum);
static void SetPolymodelProperties(bsp_info *subobj, char *props);
static void MinMaxSubmodel(poly_model *pm, bsp_info *sm, vector offset);
static void FindMinMaxForModel(poly_model *pm);
static int ReadNewModelFile(int polynum, CFILE *infile);
static void SetNormalizedTimeObjTimed(object *obj, float *normalized_time);
static void SetNormalizedTimeAnimTimed(float frame, float *normalized_time, poly_model *pm);
static void FreeAllModels();
/// Given a model pointer and an array of floats that go from 0..1, calculate the interpolated
/// position/angle of each corresponding subobject.
static void SetModelAnglesAndPosTimed(poly_model *po, float *normalized_time, uint subobj_flags);

int findtextbmpname = 0;
int findtextname = 0;

Expand Down Expand Up @@ -2217,6 +2238,7 @@ poly_model *GetPolymodelPointer(int polynum) {
return (&Poly_models[polynum]);
}

// MTS: only used in this file.
// gets the filename from a path
void ChangePolyModelName(char *src, char *dest) {
int limit;
Expand Down Expand Up @@ -2741,13 +2763,13 @@ void SetModelAnglesAndPos(poly_model *po, float *normalized_time, uint subobj_fl
}
}

vector Instance_fog_plane_stack[MAX_SUBOBJECTS];
vector Instance_fog_portal_vert_stack[MAX_SUBOBJECTS];
vector Instance_light_stack[MAX_SUBOBJECTS];
vector Instance_specular_pos[MAX_SUBOBJECTS];
vector Instance_bump_pos[MAX_SUBOBJECTS];
static vector Instance_fog_plane_stack[MAX_SUBOBJECTS];
static vector Instance_fog_portal_vert_stack[MAX_SUBOBJECTS];
static vector Instance_light_stack[MAX_SUBOBJECTS];
static vector Instance_specular_pos[MAX_SUBOBJECTS];
static vector Instance_bump_pos[MAX_SUBOBJECTS];

int Instance_light_cnt = 0;
static int Instance_light_cnt = 0;

void StartLightInstance(vector *pos, matrix *orient) {
int gouraud = 0, specular = 0, fogged = 0, bumped = 0;
Expand Down Expand Up @@ -3078,6 +3100,7 @@ int InitModels() {
return 1;
}

// MTS: used only in this file.
// Given an actual keyframe number, returns the normalized (0 to 1) position of that
// keyframe
// Handle is an index into the Poly_models array
Expand Down Expand Up @@ -3114,6 +3137,7 @@ void RemapPolyModels() {
}
}

// MTS: not used?
// Returns the total number of faces in a model
int CountFacesInPolymodel(poly_model *pm) {
int i;
Expand Down
44 changes: 22 additions & 22 deletions module/module.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* $Logfile: /DescentIII/Main/module/module.cpp $
Expand Down Expand Up @@ -97,7 +97,7 @@
#include "ddio.h"

#ifdef __LINUX__
bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filename, char *new_filename);
static bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filename, char *new_filename);
#endif

#ifdef MACINTOSH
Expand All @@ -115,7 +115,7 @@ bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filen
#endif
#if defined(WIN32) // INSTEAD OF MAKING MODULE HAVE DEPENDENCIES, PUT THE 2 DDIO FUNCTIONS I NEED HERE
// Split a pathname into its component parts
void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
char drivename[_MAX_DRIVE], dirname[_MAX_DIR];
_splitpath(srcPath, drivename, dirname, filename, ext);
if (path)
Expand All @@ -127,7 +127,7 @@ void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
// (specified in local file system syntax)
// takes a variable number of subdirectories which will be concatenated on to the path
// the last argument in the list of sub dirs *MUST* be NULL to terminate the list
void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) {
static void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) {
const char delimiter = '\\';
va_list args;
char *currentDir = NULL;
Expand Down Expand Up @@ -163,7 +163,7 @@ void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subD
#elif defined(MACINTOSH)
// DAJ why duplicate the functions that ddio provides???
// Split a pathname into its component parts
void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
#ifdef FIXED
char drivename[_MAX_DRIVE], dirname[_MAX_DIR];
_splitpath(srcPath, drivename, dirname, filename, ext);
Expand Down Expand Up @@ -214,7 +214,7 @@ void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subD
}
#elif defined(__LINUX__)
// Split a pathname into its component parts
void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
int pathStart = -1;
int pathEnd = -1;
int fileStart = -1;
Expand Down Expand Up @@ -291,7 +291,7 @@ void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
// (specified in local file system syntax)
// takes a variable number of subdirectories which will be concatenated on to the path
// the last argument in the list of sub dirs *MUST* be NULL to terminate the list
void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) {
static void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) {
const char delimiter = '/';
va_list args;
char *currentDir = NULL;
Expand Down

0 comments on commit d4560ca

Please sign in to comment.