Get rid of a bunch of duplicate code in map loading and srf*_t#1635
Get rid of a bunch of duplicate code in map loading and srf*_t#1635VReaperV merged 13 commits intoDaemonEngine:masterfrom
Conversation
|
CI fail is unrelated, and is due to Ubuntu 20.04 being phased out on azure pipelines. |
slipher
left a comment
There was a problem hiding this comment.
There are some tiny model lighting changes from Move some common stuff from srf* to srfGeneric_t and Move duplicate code from ParseFace() and ParseTriSurf() into ParseTriangleSurface(). I will try to check later if those diffs are anything.
For BSP models? I don't think other models can even be affected by this. |
|
No, it was a buildable model. |
|
That's weird... Buildings should only ever use |
df6eecc to
04e9f54
Compare
|
I can reproduce a similar small diff by adding unused fields to diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h
index fe658c0b2..c3c4a9b3d 100644
--- a/src/engine/renderer/tr_local.h
+++ b/src/engine/renderer/tr_local.h
@@ -1738,9 +1738,15 @@ enum class ssaoMode {
{
surfaceType_t surfaceType;
+ int argle;
+
// culling information
vec3_t bounds[ 2 ];
+
+ int bargle;
+
vec3_t origin;
+
float radius;
};Maybe the layout is assumed somewhere else. |
|
The lighting diffs reproduce with different OS, compiler, and GPU. I tried getting rid of The diffs go away if I disable |
|
I found the cause of that stuff in #1639. |
|
Thanks, that is very helpful! |
`srfTriangles_t` doesn't have any difference with `srfGeneric_t` now.
slipher
left a comment
There was a problem hiding this comment.
I think the last commit, NUKE srfSurfaceFace_t, should be dropped. It will just cause confusion for one of the surface types to not have its own struct. But a couple changes from that commit of changing some casts to srfGeneric_t * should be kept (these fix comments I made on earlier commits complaining of casting to an inappropriate type).
src/engine/renderer/tr_bsp.cpp
Outdated
| || *surface->data == surfaceType_t::SF_TRIANGLES ) | ||
| { | ||
| srfSurfaceFace_t *face = ( srfSurfaceFace_t * ) surface->data; | ||
| srfSurfaceFace_t* srf = ( srfSurfaceFace_t * ) surface->data; |
But this is also the case with |
OK then I complain about that one too 😛 |
|
I guess I can revert those, though I don't see much point in keeping around structs that have nothing in them other than stuff they inherit. |
|
I guess it's fine as long as there are comments on the SF_FACE etc. enum. |
|
I've added the comments into |
…angleSurface() Also moves `plane` from `srfSurfaceFace_t` to `srfSurfaceGeneric_t`, since it's the only difference between them, and plane computations were already being done on `srfSurfaceGeneric_t` anyway, so they can be moved there too.
The only other code in `FinishGenericSurface()` was duplicate from `ParseFace()`. Also moved both `ShaderForShaderNum()` and `SphereFromBounds()` closer to where they're actually used.
It is now the same as `srfGeneric_t`, so just use that instead.
| // triangle definitions | ||
| int numTriangles; | ||
| srfTriangle_t *triangles; | ||
| cplane_t plane; // Valid in: SF_FACE, SF_TRIANGLES |
There was a problem hiding this comment.
Does SF_TRIANGLES really have a plane? It doesn't make much sense and the old srfTriangles_t doesn't have it.
Also I don't think it's necessary to have comments on ones that are always valid; you can remove those if you want.
There was a problem hiding this comment.
I thought that too, but R_PlaneForSurface() was already using the first triangle's plane as surface plane for SF_TRIANGLES:
Daemon/src/engine/renderer/tr_main.cpp
Lines 1226 to 1234 in bc09529
There was a problem hiding this comment.
For code comments, I'll adjust them in a later pr, since I found some more things that can be cleaned up there, but don't want to overload this pr.
There was a problem hiding this comment.
I see. It seems R_PlaneForSurface is only used for portals.
|
LGTM |


I've run into a bunch of duplicate code while making some improvements to map processing, any improvements to which required to add more such duplication, while the code underneath is the exact same.
This pr NUKES
srfTriangles_tandsrfSurface_t, and moves all the common information between them,srfGridMesh_t, andsrfVBOMesh_t, intosrfGeneric_t.The common parts of
ParseFace()andParseTriSurf()are moved into a newParseTriangleSurface(), which is all of it except the plane calculation. The comment about.lwomodels inParseTriSurf()is irrelevant, because we don't support those.ParseTriangleSurface()andParseMesh()now useSphereFromBounds()instead ofFinishGenericSurface(), because the only difference between the 2 was just duplicated code.