- Grunt::ServerLink: all CMD_GRUNT_* handlers, send helpers, features/strings, command table 0xB24D70, s_localeIds 0xAD3004, Pending::Remove (dead server-side link, docs/0x008CE200.md); ServerLink.h stub removed - PetAction type for CGPetInfo::m_actions / pet spell actions / cursor pet action, SetAutocast 0x5D32F0 - CParticleEmitter2 fields 0x98-0x11F moved into CParticleEmitter2::Params (ctor 0x979250) - fixed16(float), C3Vector::FlushDenormals, CGxuLightQueue + static 0xC7C074, CAaSphere(), CMapLowDetail(), C2Vector()/C4Plane() out of line, SpellHistory dtor, CGDynamicObject_C GetScale/GetRawFacing - DB record operator= (PetNameCache, CGPetition, DanceCache): fixes the shallow-copy double free in AddItem - ClientSetTimer(delay, handler, param) with its five callers, IOMd5Unit::Create without container, CDataStore::GetByte / Get(int32_t&), WDataStore::GetHeaderSpace, TSHashTable::Head, TSList::IsEmpty - CameraTurnPlayer calls CVehicleCamera_C::IsTransitioningFacing 0x5FAA10 (was IsHierarchyChasingFacing) - OFFSET additions: TSHashTable::Unlink, TInstanceId dtor, DBCACHEHASH dtor (+ ItemNameCache_C dtor), CDataStoreCache ctor, BitUnpacker/RunningAverageCalculator deleting dtors, CGTooltip::GetObjectType Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
135 lines
3.0 KiB
C++
135 lines
3.0 KiB
C++
#include <cmath>
|
|
#include <cstdint>
|
|
#include "Engine/Source/Tempest/CAaSphere.h"
|
|
|
|
// VERIFY: 0e73d0a5 manual
|
|
// OFFSET: 0x006FC1E0
|
|
CAaSphere::CAaSphere() {
|
|
this->r = 0.0f;
|
|
}
|
|
|
|
// VERIFY: 96f5035c manual
|
|
// OFFSET: 0x007FA140
|
|
CAaBox CAaSphere::Box() const {
|
|
CAaBox result;
|
|
result.b.x = this->c.x - this->r;
|
|
result.b.y = this->c.y - this->r;
|
|
result.b.z = this->c.z - this->r;
|
|
result.t.x = this->c.x + this->r;
|
|
result.t.y = this->c.y + this->r;
|
|
result.t.z = this->c.z + this->r;
|
|
return result;
|
|
}
|
|
|
|
// VERIFY: 34fc52e7 manual
|
|
// OFFSET: 0x009855F0
|
|
CAaBox CAaSphere::FindExtrema(const CAaSphere* spheres, uint32_t count) {
|
|
CAaBox result;
|
|
|
|
if (!count) {
|
|
result.b.x = 0.0f;
|
|
result.b.y = 0.0f;
|
|
result.b.z = 0.0f;
|
|
result.t.x = 0.0f;
|
|
result.t.y = 0.0f;
|
|
result.t.z = 0.0f;
|
|
return result;
|
|
}
|
|
|
|
CAaBox box = spheres[0].Box();
|
|
|
|
for (uint32_t i = 1; i < count; i++) {
|
|
const CAaSphere& sphere = spheres[i];
|
|
float maxX = sphere.r + sphere.c.x;
|
|
float maxY = sphere.r + sphere.c.y;
|
|
float maxZ = sphere.r + sphere.c.z;
|
|
float minX = sphere.c.x - sphere.r;
|
|
float minY = sphere.c.y - sphere.r;
|
|
float minZ = sphere.c.z - sphere.r;
|
|
|
|
if (box.t.z > maxZ) {
|
|
maxZ = box.t.z;
|
|
}
|
|
|
|
if (box.t.y > maxY) {
|
|
maxY = box.t.y;
|
|
}
|
|
|
|
if (box.t.x > maxX) {
|
|
maxX = box.t.x;
|
|
}
|
|
|
|
if (box.b.z < minZ) {
|
|
minZ = box.b.z;
|
|
}
|
|
|
|
if (box.b.y < minY) {
|
|
minY = box.b.y;
|
|
}
|
|
|
|
if (box.b.x < minX) {
|
|
minX = box.b.x;
|
|
}
|
|
|
|
box.b.x = minX;
|
|
box.b.y = minY;
|
|
box.b.z = minZ;
|
|
box.t.x = maxX;
|
|
box.t.y = maxY;
|
|
box.t.z = maxZ;
|
|
}
|
|
|
|
result = box;
|
|
return result;
|
|
}
|
|
|
|
// VERIFY: 1d040cbb manual
|
|
// OFFSET: 0x00985750
|
|
CAaSphere CAaSphere::BoundingAccurate(const CAaSphere* spheres, uint32_t count) {
|
|
CAaSphere result;
|
|
|
|
if (!count) {
|
|
result.c.x = 0.0f;
|
|
result.c.y = 0.0f;
|
|
result.c.z = 0.0f;
|
|
result.r = 0.0f;
|
|
return result;
|
|
}
|
|
|
|
if (count == 1) {
|
|
result = spheres[0];
|
|
return result;
|
|
}
|
|
|
|
CAaBox box = FindExtrema(spheres, count);
|
|
|
|
if (box.IsEmpty()) {
|
|
result.c = box.b;
|
|
result.r = 0.0f;
|
|
return result;
|
|
}
|
|
|
|
C3Vector center;
|
|
center.x = (box.t.x + box.b.x) * 0.5f;
|
|
center.y = (box.t.y + box.b.y) * 0.5f;
|
|
center.z = 0.5f * (box.t.z + box.b.z);
|
|
|
|
float radius = 0.0f;
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
const CAaSphere& sphere = spheres[i];
|
|
float dy = sphere.c.y - center.y;
|
|
float dx = sphere.c.x - center.x;
|
|
float distance = dx * dx + dy * dy + (sphere.c.z - center.z) * (sphere.c.z - center.z);
|
|
float slack = radius - sphere.r;
|
|
|
|
if (slack < 0.0f || slack * slack < distance) {
|
|
radius = sqrt(distance) + sphere.r;
|
|
}
|
|
}
|
|
|
|
result.c = center;
|
|
result.r = radius;
|
|
return result;
|
|
}
|