mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
fix(m2): reject NaN inputs at M2Renderer::createInstance
Even with all the upstream guards I've been adding, internal callers or addon-style scripted spawns could pass NaN. Reject at the API boundary so we never hash-key with NaN coords (std::round of NaN is implementation-defined) or push a NaN instance into the model- matrix uniform buffer (GPU crash / origin render).
This commit is contained in:
parent
4cbffe17d5
commit
f96ea12fe7
1 changed files with 9 additions and 0 deletions
|
|
@ -36,6 +36,15 @@ namespace rendering {
|
|||
|
||||
uint32_t M2Renderer::createInstance(uint32_t modelId, const glm::vec3& position,
|
||||
const glm::vec3& rotation, float scale) {
|
||||
// Reject NaN inputs at the boundary — std::round of NaN is implementation-
|
||||
// defined and a NaN instance position propagates into the GPU model matrix,
|
||||
// either tripping Vulkan validation or rendering at the world origin.
|
||||
if (!std::isfinite(position.x) || !std::isfinite(position.y) ||
|
||||
!std::isfinite(position.z) || !std::isfinite(rotation.x) ||
|
||||
!std::isfinite(rotation.y) || !std::isfinite(rotation.z) ||
|
||||
!std::isfinite(scale) || scale <= 0.0f) {
|
||||
return 0;
|
||||
}
|
||||
auto modelIt = models.find(modelId);
|
||||
if (modelIt == models.end()) {
|
||||
LOG_WARNING("Cannot create instance: model ", modelId, " not loaded");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue