ValveSoftware / ValveSoftware/source-sdk-2013
Model scaling turns quadratic for one-bone models compiled without $staticprop
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10k
- Forks
- 3k
- Avg merge
- 8d 11h
- Merged PRs (30d)
- 2
Description
Expected behavior: Any given prop_dynamic with a modelscale=2 KV should scale to 2x original size.
Observed behavior: In the specific case where a prop_dynamic's model has only one bone and was compiled without the $staticprop flag, a modelscale=2 KV is effectively scaling to 4x original size.
This is happening because it's an unintended case where we're accidentally hitting into two scaling codepaths that are otherwise mutually exclusive:
Path A (gated by STUDIOHDR_FLAGS_STATIC_PROP):
https://github.com/ValveSoftware/source-sdk-2013/blob/88fa198fba3fb85d46d4c95018254693fdc3af0a/src/game/client/c_baseanimating.cpp#L2931-L2937
Path B (gated by numbones() == 1):
https://github.com/ValveSoftware/source-sdk-2013/blob/88fa198fba3fb85d46d4c95018254693fdc3af0a/src/game/client/c_baseanimating.cpp#L3502
I'd simply forgotten to add $staticprop to my model so this was an easy fix for me... but I suspect there's at least a few cases for animated single-bone props? numbones() == 1 seems like quite the hack in the first place, so unifying the Path A/B conditions under STUDIOHDR_FLAGS_STATIC_PROP seems like an ideal fix.
In the meantime, anyone encountering this who cannot use $staticprop will instead need to resort to adding a 2nd dummy bone or otherwise try taking the square root of their desired scale factor.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/game/client/c_baseanimating.cpp at the linked sections around lines 2931-2937 and 3502, and trace how STUDIOHDR_FLAGS_STATIC_PROP and numbones() == 1 select the scaling paths. Reproduce the issue with a one-bone model compiled without $staticprop and modelscale=2, then verify that it scales to 2x rather than 4x while existing static-prop behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100