diff --git a/Assets/Scripts/Data/QModel.cs b/Assets/Scripts/Data/QModel.cs index 7524efa..e5724f5 100644 --- a/Assets/Scripts/Data/QModel.cs +++ b/Assets/Scripts/Data/QModel.cs @@ -13,6 +13,7 @@ public class QModel private const int MaxMapHulls = 4; // Should correspond to MAX_MAP_HULLS [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] public string name; + public uint pathId; public bool needLoad; public QModelType type; @@ -23,7 +24,8 @@ public class QModel // Volume occupied by the model graphics public QVec3 mins, maxs; - public float radius; + public QVec3 ymins, ymaxs; + public QVec3 rmins, rmaxs; // Solid volume for clipping public bool clipBox; @@ -74,6 +76,15 @@ public class QModel public IntPtr lightData; // Array of bytes [MarshalAs(UnmanagedType.LPStr)] public string entities; + public bool visWarn; + public int bspVersion; + + public uint meshvbo; + public uint meshIndexesVbo; + public int vboIndexOfs; + public int vboXyzOfs; + public int vboStofs; + public IntPtr userCache; } diff --git a/Assets/Scripts/Modules/RenderModule.Interop.cs b/Assets/Scripts/Modules/RenderModule.Interop.cs index 05c97d3..146190d 100644 --- a/Assets/Scripts/Modules/RenderModule.Interop.cs +++ b/Assets/Scripts/Modules/RenderModule.Interop.cs @@ -14,6 +14,7 @@ public partial class RenderModule: CallbackHandler target = TargetPtr, UploadAliasModel = CreateCallback(Callback_UploadAliasModel), + UploadBrushModel = CreateCallback(Callback_UploadBrushModel), }; RegisterCallbacks(callbacks); @@ -28,6 +29,7 @@ public partial class RenderModule: CallbackHandler public IntPtr target; public IntPtr UploadAliasModel; + public IntPtr UploadBrushModel; } [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] @@ -63,4 +65,13 @@ public partial class RenderModule: CallbackHandler triangles.ToStructArray(header.numTriangles), stVerts.ToStructArray(header.numVerts)); } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int UploadBrushModelCallback(IntPtr target, QModel model); + + [MonoPInvokeCallback(typeof(UploadBrushModelCallback))] + private static int Callback_UploadBrushModel(IntPtr target, QModel model) + { + return GetSelf(target).UploadBrushModel(model); + } } diff --git a/Assets/Scripts/Modules/RenderModule.cs b/Assets/Scripts/Modules/RenderModule.cs index 1863a48..bbab168 100644 --- a/Assets/Scripts/Modules/RenderModule.cs +++ b/Assets/Scripts/Modules/RenderModule.cs @@ -70,4 +70,13 @@ public partial class RenderModule xPos += 0.5f; return 1; } + + private int UploadBrushModel(QModel model) + { + if (model.type != QModelType.Brush) + return -1; + + Debug.Log($"Brush model '{model.name}' with {model.numLeafs} leafs, {model.numVertices} vertices, {model.numSurfaces} surfaces"); + return 1; + } } diff --git a/engine/Quake/gl_model.h b/engine/Quake/gl_model.h index 31e2e48..c648bfb 100644 --- a/engine/Quake/gl_model.h +++ b/engine/Quake/gl_model.h @@ -517,5 +517,6 @@ byte *Mod_NoVisPVS (qmodel_t *model); void Mod_SetExtraFlags (qmodel_t *mod); int UQ_GL_UploadAliasModel(qmodel_t *model, aliashdr_t *aliashdr, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts); +int UQ_GL_UploadBrushModel(qmodel_t *model); #endif // __MODEL__ diff --git a/engine/Quake/gl_rmisc.c b/engine/Quake/gl_rmisc.c index 4aac822..cc644c7 100644 --- a/engine/Quake/gl_rmisc.c +++ b/engine/Quake/gl_rmisc.c @@ -401,6 +401,8 @@ void R_NewMap (void) GL_BuildBModelVertexBuffer (); //ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel + UQ_GL_UploadBrushModel(cl.worldmodel); + r_framecount = 0; //johnfitz -- paranoid? r_visframecount = 0; //johnfitz -- paranoid? diff --git a/engine/UniQuake/gl_uniquake.c b/engine/UniQuake/gl_uniquake.c index 395d080..9325d49 100644 --- a/engine/UniQuake/gl_uniquake.c +++ b/engine/UniQuake/gl_uniquake.c @@ -11,6 +11,7 @@ typedef struct unity_glcalls_s void *target; int(*UploadAliasModel)(void *target, const char *name, aliashdr_t *aliashdr, maliasframedesc_t *frames, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts); + int(*UploadBrushModel)(void *target, qmodel_t *model); } unity_glcalls_t; const unity_glcalls_t *unity_glcalls; @@ -21,3 +22,8 @@ int UQ_GL_UploadAliasModel(qmodel_t *model, aliashdr_t *aliashdr, trivertx_t **p // so we pass along the pointer to the first frame struct which allows us to manually marshal the entire array. return unity_glcalls->UploadAliasModel(unity_glcalls->target, model->name, aliashdr, &aliashdr->frames[0], poseVerts, triangles, stVerts); } + +int UQ_GL_UploadBrushModel(qmodel_t *model) +{ + return unity_glcalls->UploadBrushModel(unity_glcalls->target, model); +}