Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glass shatter effect does not work correctly #130

Open
aufau opened this issue Jan 27, 2020 · 2 comments
Open

Glass shatter effect does not work correctly #130

aufau opened this issue Jan 27, 2020 · 2 comments
Labels
enhancement good first issue Issues recommended for new contributors

Comments

@aufau
Copy link
Member

aufau commented Jan 27, 2020

Example:
shot0008

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)
shot0015
shot0010
shot0013

@aufau aufau changed the title Glass shatter effect is broken Glass shatter effect does not work correctly Jan 27, 2020
@aufau
Copy link
Member Author

aufau commented Feb 4, 2020

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.

@aufau
Copy link
Member Author

aufau commented Feb 11, 2020

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.

@aufau aufau added the good first issue Issues recommended for new contributors label May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Issues recommended for new contributors
Projects
None yet
Development

No branches or pull requests

1 participant