mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 17:43:51 +00:00
fix(render): code quality cleanup
Magic number elimination: - Create protocol_constants.hpp, warden_constants.hpp, render_constants.hpp, ui_constants.hpp - Replace ~55 magic numbers across game_handler, warden_handler, m2_renderer_render Reduce nesting depth: - Extract 5 parseEffect* methods from handleSpellLogExecute (max indent 52 → 16 cols) - Extract resolveSpellSchool/playSpellCastSound/playSpellImpactSound from 3× duplicate audio blocks in handleSpellGo - Flatten SMSG_INVENTORY_CHANGE_FAILURE with early-return guards - Extract drawScreenEdgeVignette() for 3 duplicate vignette blocks DRY extract patterns: - Replace 12 compound expansion checks with isPreWotlk() across movement_handler (9), chat_handler (1), social_handler (1) const to constexpr: - Promote 23+ static const arrays/scalars to static constexpr across 12 source files Error handling: - Convert PIN auth from exceptions to std::optional<PinProof> - Add [[nodiscard]] to 15+ initialize/parse methods - Wrap ~20 unchecked initialize() calls with LOG_WARNING/LOG_ERROR Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
This commit is contained in:
parent
2e8856bacd
commit
97106bd6ae
41 changed files with 849 additions and 424 deletions
|
|
@ -2130,7 +2130,9 @@ void CharacterRenderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet,
|
|||
}
|
||||
const float renderRadius = static_cast<float>(envSizeOrDefault("WOWEE_CHAR_RENDER_RADIUS", 130));
|
||||
const float renderRadiusSq = renderRadius * renderRadius;
|
||||
const float characterCullRadius = 2.0f; // Estimate character radius for frustum testing
|
||||
// Default frustum-cull radius when model bounds aren't available.
|
||||
// 4.0 covers Tauren, mounted characters, and most creature models.
|
||||
constexpr float kDefaultCharacterCullRadius = 4.0f;
|
||||
const glm::vec3 camPos = camera.getPosition();
|
||||
|
||||
// Extract frustum planes for per-instance visibility testing
|
||||
|
|
@ -2175,8 +2177,17 @@ void CharacterRenderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet,
|
|||
// Distance cull: skip if beyond render radius
|
||||
if (distSq > renderRadiusSq) continue;
|
||||
|
||||
// Compute per-instance bounding radius from model data when available.
|
||||
float cullRadius = kDefaultCharacterCullRadius;
|
||||
auto mIt = models.find(instance.modelId);
|
||||
if (mIt != models.end()) {
|
||||
float modelR = mIt->second.data.boundRadius;
|
||||
if (modelR > 0.01f)
|
||||
cullRadius = std::max(kDefaultCharacterCullRadius, modelR * std::max(0.001f, instance.scale));
|
||||
}
|
||||
|
||||
// Frustum cull: skip if outside view frustum
|
||||
if (!frustum.intersectsSphere(instance.position, characterCullRadius)) continue;
|
||||
if (!frustum.intersectsSphere(instance.position, cullRadius)) continue;
|
||||
}
|
||||
|
||||
if (!instance.cachedModel) continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue