ValveSoftware / ValveSoftware/source-sdk-2013

Model scaling turns quadratic for one-bone models compiled without $staticprop

Open
#1,974 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.