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

Mesh scaling factor madness #15811

Open
appgurueu opened this issue Feb 19, 2025 · 3 comments
Open

Mesh scaling factor madness #15811

appgurueu opened this issue Feb 19, 2025 · 3 comments
Labels
Bug Issues that were confirmed to be a bug @ Client rendering @ Documentation Improvements or additions to documentation

Comments

@appgurueu
Copy link
Contributor

Problem

We are in a weird situation regarding mesh scaling.

breakages.md says:

remove space multiplier for models (*10)

There is a vague hint of the same multiplier in lua_api.md, but.. it isn't stated explicitly?

Note: Just like model dimensions, the relative position in set_attach must be multiplied by 10 compared to world positions.

I would have expected one of two things:

  • Based on my experience as a modder some years ago: That due to an engine inconsistency entities use 10x space and nodes use 1x space.
  • Based on the docs (and the code): That everything uses 10x space.

Neither is the case. What actually seems to be the case:

  • Static .obj models use 1x space for nodes and 10x space for entities.
  • SkinnedMesh models (.b3d, .gltf) use 10x space for both nodes and entities.

This is due to a bug in the code which causes SkinnedMeshes not to be scaled when used for nodes: resetAnimation overwrites the scaled vertices in the mesh buffers with unscaled vertices from the weights.

The bug was accidentally fixed for most models in 2143709: Recalculating normals ended up calling resetAnimation.
By not recalculating normals anymore for many models, these models would now be properly scaled.

Mods / games that had adapted to the wrong scaling (like Wuzzy's eyeballs) would now have nodes that were too large by a factor of 10: #15576, and the bug was put back in to fix it: d4ccc8d.

Solution

We should probably document the status quo more accurately, both in breakages.md but more importantly in lua_api.md.

We probably don't want to break such fundamental scaling factors, so we probably have to keep this inconsistent inconsistency around as-is, including .obj not requiring the 10x scale factor for nodes.

We should then also clean up the code and explicitly just not scale skinned meshes to begin with.

@appgurueu appgurueu added Bug Issues that were confirmed to be a bug @ Documentation Improvements or additions to documentation @ Client rendering labels Feb 19, 2025
@nininik0
Copy link

ive also noticed that .b3d mesh BLOCKS arent scaling when i try to set their visual_scale to something

@Desour
Copy link
Member

Desour commented Feb 19, 2025

We could add a scale_mesh_by_10 node def / object property field, which is false by default for nodes and for .obj, and otherwise true by default. We could even leave it unimplemented at first, and only allow the correct default value (=> and delight in the frustration of modders who can only set a value that they don't like >:D). Then, we could later fix the stuff and change the default, without breaking everything.

And functions that take values in BS space, or rather which ever the mesh's coordinate system is, (Is there something else than set_bone_override()?) also need some way to make it work for old and new servers.

@sfan5
Copy link
Collaborator

sfan5 commented Feb 19, 2025

Offtopic but another thing I stumbled upon is that backface_culling apparently defaults to false for mesh nodes. Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Client rendering @ Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants