Characters now render correctly even if their scale is incredibly large or incredibly small. - #144
Conversation
| } | ||
|
|
||
| const float kCullRadius = 2.0f; | ||
| float kCullRadius = 2.0f; |
There was a problem hiding this comment.
This is a global variable, so if it's changed inside one object, it's changed for every single object being drawn. I don't think that's the right solution. You could copy the constant's value to a local variable inside the function(s) it's used in, or you could make it an member variable of the movement object class, so that it is instanced per object.
| if (GetScriptParams()->HasParam("Character Scale")) { | ||
| rigged_object_->SetCharScale(GetScriptParams()->ASGetFloat("Character Scale")); | ||
|
|
||
| float new_frust = GetScriptParams()->ASGetFloat("Character Scale") * 2; |
There was a problem hiding this comment.
This ASGetFloat call is already being done two lines above. Ideally we'd get rid of all these per-frame calls into the angelscript context entirely because this sort of variable lookup is relatively slow (compared to using the value of a variable defined and used from C++). But since you didn't put that code there, you definitely don't have to fix it. But ideally you also should avoid multiplying it.
For now, I think it'd be best to put the result of ASGetFloat in a local variable and reuse the value here.
There was a problem hiding this comment.
Oh, I expanded the code above. For some reason I assumed this was in draw, due to "frust" being the name of the variable. This is actually in CreateRiggedObject, so it's less of a concern.
Still, generally a good practice to avoid copying code that calls into chains of accessors. Just do it once in the function, assign it to a local variable, and reuse the result.
| kCullRadius = 200.0f; | ||
| } else { | ||
| kCullRadius = new_frust; | ||
| } |
There was a problem hiding this comment.
This code is basically kCullRadius = clamp(new_frust, 2.0f, 200.0f);
Not sure if we have such a clamp implementation in our codebase already, but if we do, this would be a perfect place to use it.
| char_scale = val * character_script_getter->GetDefaultScale(); | ||
| model_char_scale = char_scale / character_script_getter->GetModelScale(); | ||
| float default_scale = character_script_getter->GetDefaultScale(); | ||
| char_scale = val * default_scale <= 0.01f ? 0.01f : val * default_scale; |
There was a problem hiding this comment.
like clamp above, this would be a good use for a max function
|
|
||
| I am gonna note that this really does only (hopefully) fix rendering stuff, very large or small characters are still wonk in most other gameplay ways (ragdolling/ledge-climbing/fighting and such) though that makes sense considering Overgrowth never was built around that. | ||
| Well... Except for rats having bad ledge-climb stuff, dog attacks sometimes hitting even if their fist/foot isn't close to the player, I think cats and wolves suffer from this issue too. | ||
| I think that the hitbox issue can be solved via the "range_adjust" thingy I put up a while back. (This _does_ kinda come with the issue of it being cumbersome to have copies of each different attack for each different race just so they have fitting range_adjust values, but personally I think it's worth it for the sake of fairness/balance since getting hit by phantom dog paws isn't the most fun.) No newline at end of file |
There was a problem hiding this comment.
This shouldn't be checked in, unless it's in the commit message or comments/description of the PR.
If the code itself is confusing, there may be value to putting some of this in comments directly with the code it applies to.
|
Updates: |
There's a textfile that explains stuffs.