You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While glass shatter effect is implemented in the cgame code, the error steams from CG_R_GET_BMODEL_VERTS syscall implementation. The syscall is supposed to find and return a quadrilateral surface in 3d space, which will be replaced and covered by glass shards in the cgame code, for given glass brush model. The reasonable assumption here is that:
Assumption 1: The glass brush model is a "thin" cuboid with quadrilateral base.
Current code looks for largest surface in the brush model. Error is that these brush models are partitioned by BSP algorithm so such surface is not what the author expected (largest wall of the model). On the screenshot above surface happens to be a triangle, hence the catastrophic failure. 4th corner coordinates are uninitialized, (0, 0, 0).
Solution:
Replace RE_GetBModelVerts() algorithm with one that finds a quadrilateral surface covering the glass model under the Assumption 1.
I believe the syscall was intended and used only for this effect so there is no harm in changing it.
Some other examples (less catastrophic due to partitioned surfaces being rectangles)
The text was updated successfully, but these errors were encountered:
It turns out there are glass models with more complicated shapes eg on ctf_ns_streets. There is nothing we can do with them with current cgame algorithm, but at least engine should not error and fallback to something vaguely reasonable.
There are also these small, "polygonal" windows in bases on ctf_imperial. I think old algorithm is ok for this (find largest player-facing surface or something along these lines). It only requires combining surfaces on the same plane, split by bsp algorithm and treating them as a single, large surface.
Example:
While glass shatter effect is implemented in the cgame code, the error steams from CG_R_GET_BMODEL_VERTS syscall implementation. The syscall is supposed to find and return a quadrilateral surface in 3d space, which will be replaced and covered by glass shards in the cgame code, for given glass brush model. The reasonable assumption here is that:
Assumption 1: The glass brush model is a "thin" cuboid with quadrilateral base.
Current code looks for largest surface in the brush model. Error is that these brush models are partitioned by BSP algorithm so such surface is not what the author expected (largest wall of the model). On the screenshot above surface happens to be a triangle, hence the catastrophic failure. 4th corner coordinates are uninitialized, (0, 0, 0).
Solution:
Replace RE_GetBModelVerts() algorithm with one that finds a quadrilateral surface covering the glass model under the Assumption 1.
I believe the syscall was intended and used only for this effect so there is no harm in changing it.
Some other examples (less catastrophic due to partitioned surfaces being rectangles)
The text was updated successfully, but these errors were encountered: