mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-14 08:23:52 +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
|
|
@ -63,7 +63,9 @@ static std::vector<uint8_t> randomizePinDigits(const std::string& pinDigits,
|
|||
if (idx == 0xFF) {
|
||||
throw std::runtime_error("PIN digit not found in remapped grid");
|
||||
}
|
||||
out.push_back(static_cast<uint8_t>(idx + 0x30)); // ASCII '0'+idx
|
||||
// PIN grid encodes each digit as its ASCII character ('0'..'9') for the
|
||||
// server-side HMAC computation — this matches Blizzard's auth protocol.
|
||||
out.push_back(static_cast<uint8_t>(idx + '0'));
|
||||
}
|
||||
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ bool DBCFile::load(const std::vector<uint8_t>& dbcData) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Validate record size matches field count
|
||||
// DBC fields are fixed-width uint32 (4 bytes each); record size must match.
|
||||
// Mismatches indicate a corrupted header or unsupported DBC variant.
|
||||
if (recordSize != fieldCount * 4) {
|
||||
LOG_WARNING("DBC record size mismatch: recordSize=", recordSize,
|
||||
" but fieldCount*4=", fieldCount * 4);
|
||||
|
|
|
|||
|
|
@ -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