From a456368a989b8a4fc00822357ad3e3c9034be71d Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 22 May 2024 08:16:41 +0500 Subject: [PATCH] autoblend key setup --- tools/quake3/q3map2/map.cpp | 3 +++ tools/quake3/q3map2/model.cpp | 7 +++++-- tools/quake3/q3map2/q3map2.h | 6 +++++- tools/quake3/q3map2/surface.cpp | 3 ++- tools/quake3/q3map2/surface_foliage.cpp | 2 +- tools/quake3/q3map2/surface_meta.cpp | 2 ++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/quake3/q3map2/map.cpp b/tools/quake3/q3map2/map.cpp index 485b0dd6..2fff6b2d 100644 --- a/tools/quake3/q3map2/map.cpp +++ b/tools/quake3/q3map2/map.cpp @@ -1594,6 +1594,8 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntit if ( lightmapSampleSize != 0 ) Sys_Printf( "Entity %d (%s) has lightmap sample size of %d\n", mapEnt.mapEntityNum, classname, lightmapSampleSize ); + const int autoblendIdx = mapEnt.boolForKey( "_autoblend" )? ++mapDrawSurface_t::autoblendMaxIdx : 0; + /* attach stuff to everything in the entity */ for ( brush_t& brush : mapEnt.brushes ) { @@ -1604,6 +1606,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntit brush.lightmapScale = lightmapScale; brush.celShader = celShader; brush.shadeAngleDegrees = shadeAngle; + brush.autoblendIdx = autoblendIdx; } for ( parseMesh_t *patch = mapEnt.patches; patch != NULL; patch = patch->next ) diff --git a/tools/quake3/q3map2/model.cpp b/tools/quake3/q3map2/model.cpp index 875767ee..4d3a82ea 100644 --- a/tools/quake3/q3map2/model.cpp +++ b/tools/quake3/q3map2/model.cpp @@ -992,7 +992,7 @@ default_CLIPMODEL: adds a picomodel into the bsp */ -void InsertModel( const char *name, const char *skin, int frame, const Matrix4& transform, const std::list *remaps, shaderInfo_t *celShader, entity_t& entity, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth ){ +void InsertModel( const char *name, const char *skin, int frame, const Matrix4& transform, const std::list *remaps, shaderInfo_t *celShader, entity_t& entity, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth, int autoblendIdx ){ int i, j; const Matrix4 nTransform( matrix4_for_normal_transform( transform ) ); const bool transform_lefthanded = MATRIX4_LEFTHANDED == matrix4_handedness( transform ); @@ -1138,6 +1138,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& ds->entityNum = entity.mapEntityNum; ds->castShadows = castShadows; ds->recvShadows = recvShadows; + ds->autoblendIdx = autoblendIdx; /* set shader */ ds->shaderInfo = si; @@ -1404,8 +1405,10 @@ void AddTriangleModels( entity_t& eparent ){ if ( e.read_keyvalue( clipDepth, "_clipdepth" ) ) Sys_Printf( "misc_model %s has autoclip depth of %.3f\n", model, clipDepth ); + const int autoblendIdx = e.boolForKey( "_autoblend" )? ++mapDrawSurface_t::autoblendMaxIdx : 0; + /* insert the model */ - InsertModel( model, skin, frame, transform, &remaps, celShader, eparent, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle, clipDepth ); + InsertModel( model, skin, frame, transform, &remaps, celShader, eparent, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle, clipDepth, autoblendIdx ); } } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index dce4e555..dff9ab16 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -697,6 +697,7 @@ struct brush_t int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */ float lightmapScale; float shadeAngleDegrees; /* jal : entity based _shadeangle */ + int autoblendIdx; MinMax eMinmax; indexMap_t *im; @@ -859,6 +860,9 @@ struct mapDrawSurface_t /* ydnar: editor/useful numbering */ int entityNum; int surfaceNum; + + inline static int autoblendMaxIdx = 0; + int autoblendIdx = 0; }; @@ -1532,7 +1536,7 @@ tree_t FaceBSP( facelist_t& list ); /* model.c */ void assimp_init(); -void InsertModel( const char *name, const char *skin, int frame, const Matrix4& transform, const std::list *remaps, shaderInfo_t *celShader, entity_t& entity, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth ); +void InsertModel( const char *name, const char *skin, int frame, const Matrix4& transform, const std::list *remaps, shaderInfo_t *celShader, entity_t& entity, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth, int autoblendIdx ); void AddTriangleModels( entity_t& eparent ); diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 34b08caa..f0e99b09 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -770,6 +770,7 @@ mapDrawSurface_t *DrawSurfaceForSide( const entity_t& e, const brush_t& b, const ds->entityNum = b.entityNum; ds->castShadows = b.castShadows; ds->recvShadows = b.recvShadows; + ds->autoblendIdx = b.autoblendIdx; ds->planar = true; ds->planeNum = s.planenum; @@ -2806,7 +2807,7 @@ static int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceMode } /* insert the model */ - InsertModel( model.model.c_str(), NULL, 0, transform, NULL, ds->celShader, entity, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, clipDepthGlobal ); + InsertModel( model.model.c_str(), NULL, 0, transform, NULL, ds->celShader, entity, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, clipDepthGlobal, 0 ); /* return to sender */ return 1; diff --git a/tools/quake3/q3map2/surface_foliage.cpp b/tools/quake3/q3map2/surface_foliage.cpp index 4f839478..88f64c53 100644 --- a/tools/quake3/q3map2/surface_foliage.cpp +++ b/tools/quake3/q3map2/surface_foliage.cpp @@ -255,7 +255,7 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ oldNumMapDrawSurfs = numMapDrawSurfs; /* add the model to the bsp */ - InsertModel( foliage.model.c_str(), NULL, 0, matrix4_scale_for_vec3( Vector3( foliage.scale ) ), NULL, NULL, entity, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, clipDepthGlobal ); + InsertModel( foliage.model.c_str(), NULL, 0, matrix4_scale_for_vec3( Vector3( foliage.scale ) ), NULL, NULL, entity, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, clipDepthGlobal, 0 ); /* walk each new surface */ for ( i = oldNumMapDrawSurfs; i < numMapDrawSurfs; i++ ) diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index 287e97be..ea1000c8 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -73,6 +73,7 @@ struct metaTriangle_t const side_t *side; int entityNum, surfaceNum, planeNum, fogNum, sampleSize, castShadows, recvShadows; float shadeAngleDegrees; + int autoblendIdx; Plane3f plane; Vector3 lightmapAxis; std::array m_vertices; @@ -319,6 +320,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ src.fogNum = ds->fogNum; src.sampleSize = ds->sampleSize; src.shadeAngleDegrees = ds->shadeAngleDegrees; + src.autoblendIdx = ds->autoblendIdx; src.lightmapAxis = ds->lightmapAxis; metaTriangle_insert( src, { ds->verts[ ds->indexes[ i ] ],