ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.66k stars 616 forks source link

[HL25] model_t surfaces field contains invalid data #3702

Open LAGonauta opened 9 months ago

LAGonauta commented 9 months ago

I am developing a mod that aims to add SteamAudio support to GoldSrc, but since the HL25 update I am having trouble getting the BSP data from the engine.

I am using GetEntityByIndex(0) to get the map entity, and then processing the model like this:

cl_entity_s* map = gEngfuncs.GetEntityByIndex(0);
model_s* mapModel = map->model;

// Process every surface
for (int i = 0; i < mapModel->nummodelsurfaces; ++i)
{
  msurface_t surface = mapModel->surfaces[mapModel->firstmodelsurface + i];
  // ... processing code ...
}

However, after engine HL25, the surface returned by mapModel->surfaces is not always valid so I cannot get all the polys of the model.

Before HL25: image

After HL25: image

I am not sure if it is a matter of updating com_model.h, but it would be really helpful to have this fixed. I don't really want to manually parse and load the map BSP... Thank you!

SamVanheer commented 9 months ago

model_t's contents vary depending on which renderer is in use. Chances are it's changed again to accommodate the shader functionality. If you need to access BSP data you're better off loading it yourself.

jeefo commented 9 months ago

This helped me, when tracing light-level server-side: https://github.com/yapb/linkage/commit/c91a51d769f10a38637af7ee9f03ed76d1fc206c , i.e. msuraface_t contains additional displaylist_t field on struct end with hl25.

LAGonauta commented 9 months ago

This helped me, when tracing light-level server-side: yapb/linkage@c91a51d , i.e. msuraface_t contains additional displaylist_t field on struct end with hl25.

This fixed it, thanks :) I will use your solution in the interim, but it is good to know that it will work again when the SDK gets updated.

tschumann commented 8 months ago

Thanks. Any similar change for the software renderer?

On Tuesday, December 12, 2023, Felipe @.***> wrote:

This helped me, when tracing light-level server-side: @.*** https://github.com/yapb/linkage/commit/c91a51d769f10a38637af7ee9f03ed76d1fc206c , i.e. msuraface_t contains additional displaylist_t field on struct end with hl25.

This fixed it, thanks :) I will use your solution in the interim, but it is good to know that it will work again when the SDK gets updated.

— Reply to this email directly, view it on GitHub https://github.com/ValveSoftware/halflife/issues/3702#issuecomment-1851171541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA34IYXANNLPXRXPCU7MWN3YI6ZNFAVCNFSM6AAAAABAO225POVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJRGE3TCNJUGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>