mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-16 01:03:51 +00:00
refactor: extract color write mask, name frustum epsilon, add comments
- vk_pipeline: extract kColorWriteAll constant from 4 duplicated RGBA bitmask expressions across blend mode functions, with why-comment - frustum: name kMinNormalLenSq epsilon (1e-8) with why-comment — prevents division by zero on degenerate planes - dbc_loader: add why-comment on DBC field width validation — all fields are fixed 4-byte uint32 per format spec - pin_auth: replace 0x30 hex literal with '0' char constant, add why-comment on ASCII encoding for server HMAC compatibility
This commit is contained in:
parent
ef787624fe
commit
548828f2ee
4 changed files with 19 additions and 11 deletions
|
|
@ -64,7 +64,10 @@ void Frustum::extractFromMatrix(const glm::mat4& vp) {
|
|||
|
||||
void Frustum::normalizePlane(Plane& plane) {
|
||||
float lenSq = glm::dot(plane.normal, plane.normal);
|
||||
if (lenSq > 0.00000001f) {
|
||||
// Skip normalization for degenerate planes (near-zero normal) to avoid
|
||||
// division by zero or amplifying floating-point noise into huge normals.
|
||||
constexpr float kMinNormalLenSq = 1e-8f;
|
||||
if (lenSq > kMinNormalLenSq) {
|
||||
float invLen = glm::inversesqrt(lenSq);
|
||||
plane.normal *= invLen;
|
||||
plane.distance *= invLen;
|
||||
|
|
|
|||
|
|
@ -202,18 +202,22 @@ VkPipeline PipelineBuilder::build(VkDevice device, VkPipelineCache cache) const
|
|||
return pipeline;
|
||||
}
|
||||
|
||||
// All RGBA channels enabled — used by every blend mode since we never need to
|
||||
// mask individual channels (WoW's fixed-function pipeline always writes all four).
|
||||
static constexpr VkColorComponentFlags kColorWriteAll =
|
||||
VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
|
||||
VkPipelineColorBlendAttachmentState PipelineBuilder::blendDisabled() {
|
||||
VkPipelineColorBlendAttachmentState state{};
|
||||
state.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
state.colorWriteMask = kColorWriteAll;
|
||||
state.blendEnable = VK_FALSE;
|
||||
return state;
|
||||
}
|
||||
|
||||
VkPipelineColorBlendAttachmentState PipelineBuilder::blendAlpha() {
|
||||
VkPipelineColorBlendAttachmentState state{};
|
||||
state.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
state.colorWriteMask = kColorWriteAll;
|
||||
state.blendEnable = VK_TRUE;
|
||||
state.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
state.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
|
|
@ -226,8 +230,7 @@ VkPipelineColorBlendAttachmentState PipelineBuilder::blendAlpha() {
|
|||
|
||||
VkPipelineColorBlendAttachmentState PipelineBuilder::blendPremultiplied() {
|
||||
VkPipelineColorBlendAttachmentState state{};
|
||||
state.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
state.colorWriteMask = kColorWriteAll;
|
||||
state.blendEnable = VK_TRUE;
|
||||
state.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||
state.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
|
|
@ -240,8 +243,7 @@ VkPipelineColorBlendAttachmentState PipelineBuilder::blendPremultiplied() {
|
|||
|
||||
VkPipelineColorBlendAttachmentState PipelineBuilder::blendAdditive() {
|
||||
VkPipelineColorBlendAttachmentState state{};
|
||||
state.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
state.colorWriteMask = kColorWriteAll;
|
||||
state.blendEnable = VK_TRUE;
|
||||
state.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
state.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue