mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-12 16:21:04 +02:00
135 lines
5.1 KiB
C++
135 lines
5.1 KiB
C++
/*
|
|
===========================================================================
|
|
|
|
IceTech GPL Source Code
|
|
Copyright (C) 2026 Justin Marshall
|
|
|
|
This file is part of the IceTech GPL Source Code (?IceTech Source Code?).
|
|
|
|
IceTech 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.
|
|
|
|
IceTech 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 IceTech Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
In addition, the IceTech 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 IceTech 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 Justin Marshall, justinmarshall20@gmail.com
|
|
|
|
===========================================================================
|
|
*/
|
|
|
|
#ifndef __MODELDECAL_H__
|
|
#define __MODELDECAL_H__
|
|
|
|
/*
|
|
===============================================================================
|
|
|
|
Decals are lightweight primitives for bullet / blood marks.
|
|
Decals with common materials will be merged together, but additional
|
|
decals will be allocated as needed. The material should not be
|
|
one that receives lighting, because no interactions are generated
|
|
for these lightweight surfaces.
|
|
|
|
FIXME: Decals on models in portalled off areas do not get freed
|
|
until the area becomes visible again.
|
|
|
|
===============================================================================
|
|
*/
|
|
|
|
const int NUM_DECAL_BOUNDING_PLANES = 6;
|
|
|
|
typedef struct decalProjectionInfo_s {
|
|
idVec3 projectionOrigin;
|
|
idBounds projectionBounds;
|
|
idPlane boundingPlanes[NUM_DECAL_BOUNDING_PLANES];
|
|
idPlane fadePlanes[2];
|
|
idPlane textureAxis[2];
|
|
const idMaterial* material;
|
|
bool parallel;
|
|
float fadeDepth;
|
|
int startTime;
|
|
#ifdef QUAKE4
|
|
float maxAngle;
|
|
#endif
|
|
bool force;
|
|
} decalProjectionInfo_t;
|
|
|
|
|
|
class idRenderModelDecal {
|
|
public:
|
|
idRenderModelDecal(void);
|
|
~idRenderModelDecal(void);
|
|
|
|
static idRenderModelDecal* Alloc(void);
|
|
static void Free(idRenderModelDecal* decal);
|
|
|
|
// Creates decal projection info.
|
|
static bool CreateProjectionInfo(decalProjectionInfo_t& info, const idFixedWinding& winding, const idVec3& projectionOrigin, const bool parallel, const float fadeDepth, const idMaterial* material, const int startTime);
|
|
|
|
// Transform the projection info from global space to local.
|
|
static void GlobalProjectionInfoToLocal(decalProjectionInfo_t& localInfo, const decalProjectionInfo_t& info, const idVec3& origin, const idMat3& axis);
|
|
|
|
// Creates a decal on the given model.
|
|
void CreateDecal(const idRenderModel* model, const decalProjectionInfo_t& localInfo);
|
|
|
|
// Remove decals that are completely faded away.
|
|
static idRenderModelDecal* RemoveFadedDecals(idRenderModelDecal* decals, int time);
|
|
|
|
// Updates the vertex colors, removing any faded indexes,
|
|
// then copy the verts to temporary vertex cache and adds a drawSurf.
|
|
void AddDecalDrawSurf(struct viewEntity_s* space);
|
|
|
|
// Returns the next decal in the chain.
|
|
idRenderModelDecal* Next(void) const { return nextDecal; }
|
|
|
|
void ReadFromDemoFile(class idDemoFile* f);
|
|
void WriteToDemoFile(class idDemoFile* f) const;
|
|
|
|
#ifdef QUAKE4
|
|
static int GetAllocatedDecalCount(void) { return allocatedDecalCount; }
|
|
#endif
|
|
|
|
private:
|
|
static const int MAX_DECAL_VERTS = 40;
|
|
static const int MAX_DECAL_INDEXES = 60;
|
|
|
|
#ifdef QUAKE4
|
|
static int allocatedDecalCount;
|
|
#endif
|
|
|
|
const idMaterial* material;
|
|
srfTriangles_t tri;
|
|
idDrawVert verts[MAX_DECAL_VERTS];
|
|
float vertDepthFade[MAX_DECAL_VERTS];
|
|
#ifdef QUAKE4
|
|
float vertLifeSpan[MAX_DECAL_VERTS];
|
|
#endif
|
|
glIndex_t indexes[MAX_DECAL_INDEXES];
|
|
#ifdef QUAKE4
|
|
float indexStartTime[MAX_DECAL_INDEXES];
|
|
#else
|
|
int indexStartTime[MAX_DECAL_INDEXES];
|
|
#endif
|
|
idRenderModelDecal* nextDecal;
|
|
|
|
// Adds the winding triangles to the appropriate decal in the
|
|
// chain, creating a new one if necessary.
|
|
void AddWinding(const idWinding& w, const idMaterial* decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime);
|
|
|
|
// Adds depth faded triangles for the winding to the appropriate
|
|
// decal in the chain, creating a new one if necessary.
|
|
// The part of the winding at the front side of both fade planes is not faded.
|
|
// The parts at the back sides of the fade planes are faded with the given depth.
|
|
void AddDepthFadedWinding(const idWinding& w, const idMaterial* decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime);
|
|
};
|
|
|
|
#endif /* !__MODELDECAL_H__ */
|