World port: liquids, map load chain, terrain rendering in MapViewer
Liquid system ported from 12340 (LiquidSystem module, chunk/WMO liquid, wave manager, geometry factories); CMap load chain (Load, LoadWdt, low-detail WDL, lights, CreateMapObjDef, PurgeMaps); CMapChunk create/batch/vertex/index code; CMapRenderChunk; frustum stack and scene cull helpers. MapViewer renders terrain through a viewer-only shortcut (ViewerWorld.cpp). Engine fix: int render-state setters write the full pointer-sized slot (x64 texture crash). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -84,6 +84,7 @@ add_subdirectory(WoW/Source/DB)
|
||||
add_subdirectory(WoW/Source/Game)
|
||||
add_subdirectory(WoW/Source/Glue)
|
||||
add_subdirectory(WoW/Source/Magic)
|
||||
add_subdirectory(WoW/Source/LiquidSystem)
|
||||
add_subdirectory(WoW/Source/Minigame)
|
||||
add_subdirectory(WoW/Source/Net)
|
||||
add_subdirectory(WoW/Source/Object)
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define ENGINE_SOURCE_BASE_CDATAALLOCATOR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
#include <typeinfo>
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
class CDataAllocator {
|
||||
public:
|
||||
@@ -24,6 +27,17 @@ class CDataAllocator {
|
||||
void Clear(const char* fileName, int32_t lineNumber, int32_t reportLeaks);
|
||||
void* GetData(int32_t zero, const char* fileName, int32_t lineNumber);
|
||||
void PutData(void* data, const char* fileName, int32_t lineNumber);
|
||||
|
||||
template <class T>
|
||||
T* New(int32_t zero);
|
||||
};
|
||||
|
||||
// VERIFY: 6cf1bf27 manual
|
||||
// OFFSET: [0x007D4920]
|
||||
template <class T>
|
||||
T* CDataAllocator::New(int32_t zero) {
|
||||
void* data = this->GetData(zero, typeid(T).raw_name(), SLOG_OBJECT);
|
||||
return data ? new (data) T : nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
|
||||
class LightFloatBandRec;
|
||||
class LightParamsRec;
|
||||
|
||||
class C3Vector;
|
||||
class CImVector;
|
||||
class CM2Model;
|
||||
@@ -66,6 +69,9 @@ class DNLightBands {
|
||||
/* 0090 */ float m_skyboxWeight2;
|
||||
/* 0094 */ uint32_t m_cloudTypeId;
|
||||
/* 0098 */ float m_cloudWeight;
|
||||
|
||||
DNLightBands();
|
||||
void Copy(const DNLightBands* src);
|
||||
};
|
||||
|
||||
struct DNOverrideSky {
|
||||
@@ -153,6 +159,9 @@ struct DNPlanet {
|
||||
/* 0014 */ float m_scale;
|
||||
/* 0018 */ float m_baseScale;
|
||||
/* 001C */ float m_period;
|
||||
|
||||
void Initialize(const char* fileName);
|
||||
void Render();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,6 +186,10 @@ struct DNSky {
|
||||
/* 0028 */ uint16_t m_nVerts;
|
||||
/* 002A */ uint16_t m_nIndices;
|
||||
/* 002C */ float m_sphRadius;
|
||||
|
||||
void Render();
|
||||
void GenSphere(float sphRadius);
|
||||
void SetColors();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -190,6 +203,32 @@ struct DNStars {
|
||||
};
|
||||
}
|
||||
|
||||
namespace DayNight {
|
||||
float InterpFloatBand(const LightFloatBandRec* rec, int32_t now, int32_t bandIndex);
|
||||
float CalcIndividualColorFromDBRec(int32_t bandTime, const LightParamsRec* params, int32_t bandIndex);
|
||||
void LoadLightingBands(int32_t bandTime, DNLightBands* bands, LightParamsRec* params);
|
||||
float CalcFogRate(float fogStart, float fogEnd);
|
||||
void CalcColors(int32_t bandTime, DNLightBands* bands, LightParamsRec* params);
|
||||
void BlendColors(DNLightBands* dst, const DNLightBands* src, float t);
|
||||
LightParamsRec* GetLightParams(const LightRec* light, int32_t slot);
|
||||
void SetLightColors();
|
||||
DNOverrideSky* GetOverrideSky(const char* path, uint32_t flags);
|
||||
void LoadMap(int32_t zoneID);
|
||||
void LightLoad(TSGrowableArray<LightRec*>* lightArray, uint32_t a2);
|
||||
void ColorLerpBytes(CImVector* out, const CImVector* a, const CImVector* b, float t);
|
||||
void BlendOutputs(DNLightBands* dst, const DNLightBands* src, float t);
|
||||
void BlendAreaLightColors(DNLightBands* dst, const LightRec* light, int32_t clearSlot, int32_t stormSlot);
|
||||
void BlendAreaLight(DNLightBands* dst, float maxFade, const LightRec* light, int32_t clearSlot, int32_t stormSlot);
|
||||
void BlendZoneLight(DNLightBands* dst, float maxFade, const LightRec* light, float distPct, int32_t clearSlot, int32_t stormSlot);
|
||||
void DoAreaLights(DNLightBands* light, int32_t underwater);
|
||||
void UpdateFog();
|
||||
void SetDirection();
|
||||
void UpdateLighting();
|
||||
void Update(int32_t reset, const C3Vector* cameraPos);
|
||||
void SetPlanets();
|
||||
CImVector DarkenColor(CImVector colour, float scale);
|
||||
}
|
||||
|
||||
struct SMOFog {
|
||||
/* 0000 */ uint32_t m_flags;
|
||||
/* 0004 */ C3Vector m_position;
|
||||
@@ -203,4 +242,43 @@ struct SMOFog {
|
||||
/* 002C */ CImVector m_uwFogColor;
|
||||
};
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
class LightQE {
|
||||
public:
|
||||
float m_key; // +0x00
|
||||
LightRec** m_light; // +0x04
|
||||
|
||||
static int32_t s_localSort;
|
||||
|
||||
static bool HasHigherPriority(const LightQE& a, const LightQE& b);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
class LightQueue {
|
||||
public:
|
||||
void* m_vtable;
|
||||
void* m_alloc;
|
||||
uint32_t m_allocBytes;
|
||||
LightQE* m_data;
|
||||
uint32_t m_dataBytes;
|
||||
uint32_t m_chunk;
|
||||
uint32_t m_capacity;
|
||||
uint32_t m_count;
|
||||
|
||||
LightQueue(uint32_t initial, uint32_t chunk);
|
||||
~LightQueue();
|
||||
|
||||
bool Resize(uint32_t bytes, bool noClear);
|
||||
void Insert(float key, LightRec** light);
|
||||
bool Erase(uint32_t index, uint32_t count);
|
||||
void Pop(LightQE* out);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1918,9 +1918,9 @@ void CGxDevice::RsSet(EGxRenderState which, int32_t value) {
|
||||
|
||||
CGxAppRenderState& state = this->m_appRenderStates[which];
|
||||
|
||||
if (state.m_value.m_data.i[0] != value) {
|
||||
if (state.m_value.m_data.p != reinterpret_cast<void*>(static_cast<intptr_t>(value))) {
|
||||
this->IRsDirty(which);
|
||||
state.m_value.m_data.i[0] = value;
|
||||
state.m_value.m_data.p = reinterpret_cast<void*>(static_cast<intptr_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -826,9 +826,9 @@ void GxRsSet(EGxRenderState which, int32_t value) {
|
||||
|
||||
CGxAppRenderState& state = g_theGxDevicePtr->m_appRenderStates[which];
|
||||
|
||||
if (state.m_value.m_data.i[0] != value) {
|
||||
if (state.m_value.m_data.p != reinterpret_cast<void*>(static_cast<intptr_t>(value))) {
|
||||
g_theGxDevicePtr->IRsDirty(which);
|
||||
state.m_value.m_data.i[0] = value;
|
||||
state.m_value.m_data.p = reinterpret_cast<void*>(static_cast<intptr_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class CM2Lighting {
|
||||
|
||||
CM2Lighting();
|
||||
CM2Lighting(const CAaSphere& sphere);
|
||||
CM2Lighting(const C3Vector& position);
|
||||
void Reset();
|
||||
void AddAmbient(const C3Vector& color);
|
||||
void AddDiffuse(const C3Vector& color, const C3Vector& dir);
|
||||
|
||||
@@ -7863,3 +7863,30 @@ CM2Lighting::CM2Lighting(const CAaSphere& sphere) {
|
||||
this->m_liquidPlane.d = 0.0f;
|
||||
this->Initialize(nullptr, sphere);
|
||||
}
|
||||
|
||||
// OFFSET: 0x007B0F10
|
||||
CM2Lighting::CM2Lighting(const C3Vector& position) {
|
||||
this->m_sphere4.c.x = 0.0f;
|
||||
this->m_sphere4.r = 0.0f;
|
||||
this->m_sphere4.c.y = 0.0f;
|
||||
this->m_sphere4.c.z = 0.0f;
|
||||
this->m_vector18 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_vector24 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_vector30 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_vector3C = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_vector48 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_sunAmbient = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_sunDiffuse = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_sunSpecular = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_sunDir = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_fogColor = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_liquidPlane.n.x = 0.0f;
|
||||
this->m_liquidPlane.n.y = 0.0f;
|
||||
this->m_liquidPlane.n.z = 1.0f;
|
||||
this->m_liquidPlane.d = 0.0f;
|
||||
|
||||
CAaSphere sphere;
|
||||
sphere.c = position;
|
||||
sphere.r = 0.0f;
|
||||
this->Initialize(nullptr, sphere);
|
||||
}
|
||||
|
||||
@@ -137,6 +137,23 @@ class TSGrowableArray : public TSFixedArray<T> {
|
||||
void SetCount(uint32_t count);
|
||||
};
|
||||
|
||||
template <class T, uint32_t N>
|
||||
class TSCGrowableArray {
|
||||
public:
|
||||
/* 0000 */ union {
|
||||
T m_inline[N];
|
||||
TSGrowableArray<T> m_dynamic;
|
||||
};
|
||||
uint32_t m_count;
|
||||
|
||||
TSCGrowableArray();
|
||||
~TSCGrowableArray();
|
||||
T& operator[](uint32_t index);
|
||||
void BecomeDynamic();
|
||||
T* New(const T& source);
|
||||
void SetCount(uint32_t count);
|
||||
};
|
||||
|
||||
template <class T, class TKey>
|
||||
class TSHashObject {
|
||||
public:
|
||||
@@ -1529,4 +1546,50 @@ void TSBitField<T>::Load(const void* data, uint32_t bytes, int32_t bits) {
|
||||
memcpy(this->m_bits.m_data, data, bytes);
|
||||
}
|
||||
|
||||
// VERIFY: 47bab0b9 auto
|
||||
// OFFSET: [0x007917B0]
|
||||
template <class T, uint32_t N>
|
||||
T& TSCGrowableArray<T, N>::operator[](uint32_t index) {
|
||||
if (this->m_count == 0xFFFFFFFF) {
|
||||
return this->m_dynamic.m_data[index];
|
||||
}
|
||||
|
||||
return this->m_inline[index];
|
||||
}
|
||||
|
||||
// VERIFY: 2e6b9329 manual
|
||||
// OFFSET: [0x007B3B70]
|
||||
template <class T, uint32_t N>
|
||||
void TSCGrowableArray<T, N>::BecomeDynamic() {
|
||||
uint32_t count = this->m_count;
|
||||
|
||||
if (static_cast<int32_t>(count) > static_cast<int32_t>(N)) {
|
||||
count = N;
|
||||
}
|
||||
|
||||
T saved[N];
|
||||
|
||||
if (count) {
|
||||
memcpy(saved, this->m_inline, sizeof(T) * count);
|
||||
}
|
||||
|
||||
new (&this->m_dynamic) TSGrowableArray<T>();
|
||||
this->m_dynamic.Add(count, saved);
|
||||
this->m_dynamic.Add(this->m_count - count, &this->m_inline[count]);
|
||||
this->m_count = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
// INLINED
|
||||
template <class T, uint32_t N>
|
||||
void TSCGrowableArray<T, N>::SetCount(uint32_t count) {
|
||||
if (this->m_count == 0xFFFFFFFF) {
|
||||
this->m_dynamic.SetCount(count);
|
||||
} else if (count <= N) {
|
||||
this->m_count = count;
|
||||
} else {
|
||||
this->BecomeDynamic();
|
||||
this->m_dynamic.SetCount(count);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,3 +6,9 @@
|
||||
uint32_t C2iVector::MajorAxis() const {
|
||||
return abs(this->x) <= abs(this->y);
|
||||
}
|
||||
|
||||
// VERIFY: f2fd55ef auto
|
||||
// OFFSET: 0x006839F0
|
||||
bool operator<(const C2iVector& l, const C2iVector& r) {
|
||||
return l.x < r.x && l.y < r.y;
|
||||
}
|
||||
|
||||
@@ -12,4 +12,6 @@ class C2iVector {
|
||||
uint32_t MajorAxis() const;
|
||||
};
|
||||
|
||||
bool operator<(const C2iVector& l, const C2iVector& r);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,6 +74,7 @@ target_link_libraries(WowClient
|
||||
UIUtil
|
||||
Ui
|
||||
WorldClient
|
||||
LiquidSystem
|
||||
WowServices
|
||||
WowSvcs
|
||||
Triage
|
||||
|
||||
@@ -61,6 +61,7 @@ target_link_libraries(Wow
|
||||
DB
|
||||
Game
|
||||
Glue
|
||||
LiquidSystem
|
||||
Magic
|
||||
Minigame
|
||||
Net
|
||||
|
||||
@@ -117,3 +117,35 @@ CImVector DayNight::LoadLightIntBand(int32_t time, const LightParamsRec* params,
|
||||
g_lightIntBandDB.GetRecord(band + 18 * params->m_id - 17, &rec);
|
||||
return InterpolateIntBand(rec, time);
|
||||
}
|
||||
|
||||
// VERIFY: 95c2a7e6 auto
|
||||
// OFFSET: 0x007EAEF0
|
||||
float DayNight::InterpFloatBand(const LightFloatBandRec* rec, int32_t now, int32_t bandIndex) {
|
||||
if (!rec->m_num) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float t;
|
||||
int32_t lo;
|
||||
int32_t hi;
|
||||
GetBandTimeRange(rec->m_time, rec->m_num, now, lo, t, hi);
|
||||
|
||||
if (bandIndex) {
|
||||
return (rec->m_data[hi] - rec->m_data[lo]) * t + rec->m_data[lo];
|
||||
}
|
||||
|
||||
float loValue = rec->m_data[lo] * 0.027777778f;
|
||||
return loValue + (0.027777778f * rec->m_data[hi] - loValue) * t;
|
||||
}
|
||||
|
||||
// VERIFY: fb110f5d manual
|
||||
// OFFSET: 0x007ED2D0
|
||||
void DayNight::ColorLerpBytes(CImVector* out, const CImVector* a, const CImVector* b, float t) {
|
||||
float blue = b->b < a->b ? a->b - (a->b - b->b) * t : a->b + (b->b - a->b) * t;
|
||||
float green = b->g < a->g ? a->g - (a->g - b->g) * t : a->g + (b->g - a->g) * t;
|
||||
float red = b->r < a->r ? a->r - (a->r - b->r) * t : a->r + (b->r - a->r) * t;
|
||||
out->b = CMath::fint_(blue - 0.5f);
|
||||
out->g = CMath::fint_(green - 0.5f);
|
||||
out->r = CMath::fint_(red - 0.5f);
|
||||
out->a = 0xFF;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
file(GLOB_RECURSE PRIVATE_SOURCES CONFIGURE_DEPENDS "*.cpp")
|
||||
|
||||
add_library(LiquidSystem STATIC
|
||||
${PRIVATE_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(LiquidSystem
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00D43B34
|
||||
CDataAllocator Liquid::s_unk_D43B34(0x6C, 0x20);
|
||||
|
||||
// STATIC: 0x00B23F64
|
||||
float Liquid::s_unk_B23F64 = 1.0f;
|
||||
|
||||
// STATIC: 0x00B23F68
|
||||
int32_t Liquid::s_unk_B23F68 = 1;
|
||||
|
||||
// STATIC: 0x00D439E8
|
||||
IDatabase<LiquidMaterialRec>* Liquid::s_liquidMaterialDB;
|
||||
|
||||
// STATIC: 0x00D439EC
|
||||
IDatabase<LiquidTypeRec>* Liquid::s_liquidTypeDB;
|
||||
|
||||
// STATIC: 0x00D439F0
|
||||
char Liquid::s_unk_D439F0[256];
|
||||
|
||||
// STATIC: 0x00D43AF0
|
||||
int32_t Liquid::s_unk_D43AF0;
|
||||
|
||||
// STATIC: 0x00D43AF4
|
||||
int32_t Liquid::s_unk_D43AF4;
|
||||
|
||||
// STATIC: 0x00D43AF8
|
||||
int32_t Liquid::s_unk_D43AF8;
|
||||
|
||||
// STATIC: 0x00D43AFC
|
||||
int32_t Liquid::s_unk_D43AFC;
|
||||
|
||||
// VERIFY: fb13c55c auto
|
||||
// OFFSET: 0x008A1770
|
||||
int32_t Liquid::Initialize(int32_t a1, float a2, int32_t a3, const char* a4, IDatabase<LiquidTypeRec>* liquidTypeDB, IDatabase<LiquidMaterialRec>* liquidMaterialDB) {
|
||||
SStrCopy(Liquid::s_unk_D439F0, a4, sizeof(Liquid::s_unk_D439F0));
|
||||
Liquid::s_unk_B23F64 = a2;
|
||||
Liquid::s_unk_D43AF8++;
|
||||
Liquid::s_unk_D43AFC++;
|
||||
Liquid::s_unk_D43AF4 = a1;
|
||||
Liquid::s_unk_D43AF0 = a3;
|
||||
Liquid::s_unk_B23F68 = 1;
|
||||
Liquid::s_liquidTypeDB = liquidTypeDB;
|
||||
Liquid::s_liquidMaterialDB = liquidMaterialDB;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: c3031eda manual
|
||||
// OFFSET: 0x008A2400
|
||||
void Liquid::Shutdown() {
|
||||
int32_t count = Liquid::s_unk_D43AFC--;
|
||||
Liquid::s_liquidTypeDB = nullptr;
|
||||
Liquid::s_liquidMaterialDB = nullptr;
|
||||
|
||||
if (count == 1) {
|
||||
Liquid::CMaterialBank::Destroy();
|
||||
Liquid::s_unk_D43AF0 = 0;
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::Destroy();
|
||||
Liquid::ClearMaterials();
|
||||
Liquid::s_unk_D43B34.Clear(".?AVCInstance@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 58e8bcb0 auto
|
||||
// OFFSET: 0x008A1700
|
||||
void Liquid::CInstance::AddRef() {
|
||||
this->m_refCount++;
|
||||
}
|
||||
|
||||
// VERIFY: 01aeb3b0 manual
|
||||
// OFFSET: 0x008A1710
|
||||
void Liquid::CInstance::Purge() {
|
||||
this->m_geomFactory->Purge();
|
||||
}
|
||||
|
||||
// VERIFY: e803d76a auto
|
||||
// OFFSET: 0x008A1740
|
||||
int32_t Liquid::UseCameraRelativeCoords() {
|
||||
return Liquid::s_unk_D43AF4;
|
||||
}
|
||||
|
||||
// VERIFY: d02f3d04 auto
|
||||
// OFFSET: 0x008A1750
|
||||
float Liquid::WorldCoordScale() {
|
||||
return Liquid::s_unk_B23F64;
|
||||
}
|
||||
|
||||
// VERIFY: ecbae4e7 auto
|
||||
// OFFSET: 0x008A1760
|
||||
const char* Liquid::GetShaderSuffix() {
|
||||
return Liquid::s_unk_D439F0;
|
||||
}
|
||||
|
||||
// VERIFY: 6413183d manual
|
||||
// OFFSET: 0x008A1A40
|
||||
Liquid::CInstance::CInstance() {
|
||||
this->m_material = nullptr;
|
||||
this->m_settings = nullptr;
|
||||
this->m_geomFactory = nullptr;
|
||||
this->m_waveManager = nullptr;
|
||||
this->m_environment = nullptr;
|
||||
this->m_bounds.r = 0.0f;
|
||||
this->m_queued = 0;
|
||||
this->m_refCount = 1;
|
||||
}
|
||||
|
||||
// VERIFY: d1684687 manual
|
||||
// OFFSET: 0x008A1AC0
|
||||
void Liquid::CInstance::Release() {
|
||||
if (this->m_refCount-- == 1) {
|
||||
this->m_geomFactory->Release();
|
||||
this->m_environment->Release();
|
||||
|
||||
if (this->m_waveManager) {
|
||||
this->m_waveManager->Release();
|
||||
}
|
||||
|
||||
Liquid::s_unk_D43B34.PutData(this, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 7f5df1db auto
|
||||
// OFFSET: 0x008A1B00
|
||||
Liquid::CInstance* Liquid::CInstance::Create() {
|
||||
void* mem = Liquid::s_unk_D43B34.GetData(0, ".?AVCInstance@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CInstance() : nullptr;
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
#ifndef WOW_SOURCE_LIQUIDSYSTEM_LIQUID_H
|
||||
#define WOW_SOURCE_LIQUIDSYSTEM_LIQUID_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Tempest/C2Vector.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Tempest/C4Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "WoW/Source/LiquidSystem/Types.h"
|
||||
|
||||
template <class T>
|
||||
class IDatabase;
|
||||
class CGxShader;
|
||||
class CGxTex;
|
||||
class CM2Lighting;
|
||||
class CTexture;
|
||||
class LiquidMaterialRec;
|
||||
class LiquidTypeRec;
|
||||
|
||||
namespace Liquid {
|
||||
class CInstance;
|
||||
class CMaterialSettings;
|
||||
class IWaveManager;
|
||||
class IEnvironment;
|
||||
class IGeomFactory;
|
||||
|
||||
struct VSLight {
|
||||
/* 0000 */ C4Vector m_position;
|
||||
/* 0010 */ C4Vector m_color;
|
||||
/* 0020 */ C4Vector m_attenuation;
|
||||
};
|
||||
|
||||
struct VSConstants {
|
||||
/* 0000 */ C44Matrix m_projection;
|
||||
/* 0040 */ C4Vector m_fog;
|
||||
/* 0050 */ C44Matrix m_modelView;
|
||||
/* 0090 */ C44Matrix m_texTransforms[6];
|
||||
/* 0210 */ C4Vector m_sunDir;
|
||||
/* 0220 */ C4Vector m_sunAmbient;
|
||||
/* 0230 */ C4Vector m_sunDiffuse;
|
||||
/* 0240 */ C4Vector m_sunSpecular;
|
||||
/* 0250 */ VSLight m_lights[3];
|
||||
};
|
||||
|
||||
struct VSWaveConstants {
|
||||
/* 0000 */ float m_directionalPhase[4];
|
||||
/* 0010 */ float m_circularPhase[4];
|
||||
/* 0020 */ C4Vector m_directionalWaves[3];
|
||||
/* 0050 */ float unk_0050[4];
|
||||
/* 0060 */ float unk_0060[4];
|
||||
/* 0070 */ C4Vector m_circularWaves[3];
|
||||
/* 00A0 */ float unk_00A0[4];
|
||||
/* 00B0 */ float unk_00B0[4];
|
||||
};
|
||||
|
||||
struct PSConstants {
|
||||
/* 0000 */ C44Matrix m_modelViewProj;
|
||||
/* 0040 */ C4Vector m_fogColor;
|
||||
/* 0050 */ C4Vector m_cameraPos;
|
||||
};
|
||||
|
||||
struct PSProcWaterConstants {
|
||||
/* 0000 */ C4Vector m_sunDir;
|
||||
/* 0010 */ C4Vector m_sunAmbient;
|
||||
/* 0020 */ C4Vector m_sunDiffuse;
|
||||
/* 0030 */ C4Vector m_sunSpecular;
|
||||
/* 0040 */ float m_params[8];
|
||||
};
|
||||
|
||||
class IEnvironment {
|
||||
public:
|
||||
virtual ~IEnvironment();
|
||||
virtual void Release() = 0;
|
||||
virtual void SetInteriorFog(int32_t interiorFog) = 0;
|
||||
virtual void SelectLights(CM2Lighting* lighting) = 0;
|
||||
};
|
||||
|
||||
class IWaveManager {
|
||||
public:
|
||||
virtual ~IWaveManager();
|
||||
virtual void AddRef() = 0;
|
||||
virtual void Release() = 0;
|
||||
virtual void* GetData() = 0;
|
||||
virtual int32_t GetCount() = 0;
|
||||
};
|
||||
|
||||
class IGeomFactory {
|
||||
public:
|
||||
virtual ~IGeomFactory();
|
||||
virtual void Release() = 0;
|
||||
virtual void GetBuffers(EGxVertexBufferFormat format, CGxBuf** vertexBuf, CGxBuf** indexBuf, CGxBatch* batch) = 0;
|
||||
virtual void Purge() = 0;
|
||||
virtual bool SetTransform(C44Matrix* transform) = 0;
|
||||
};
|
||||
|
||||
class IMaterial {
|
||||
public:
|
||||
virtual ~IMaterial();
|
||||
virtual void Release() = 0;
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings) = 0;
|
||||
};
|
||||
|
||||
class CMaterialProcWater : public IMaterial {
|
||||
public:
|
||||
static int32_t s_refCount;
|
||||
static CGxShader* s_vertexShaders[4];
|
||||
static CGxShader* s_pixelShader;
|
||||
|
||||
static CMaterialProcWater* Create();
|
||||
|
||||
virtual ~CMaterialProcWater();
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
|
||||
CMaterialProcWater();
|
||||
};
|
||||
|
||||
class CMaterialProcWaterFFP : public IMaterial {
|
||||
public:
|
||||
static CMaterialProcWaterFFP* Create();
|
||||
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
};
|
||||
|
||||
class CMaterialWater : public IMaterial {
|
||||
public:
|
||||
static int32_t s_refCount;
|
||||
static CGxShader* s_vertexShaders[4];
|
||||
static CGxShader* s_pixelShader;
|
||||
|
||||
static CMaterialWater* Create();
|
||||
|
||||
virtual ~CMaterialWater();
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
|
||||
CMaterialWater();
|
||||
};
|
||||
|
||||
class CMaterialWaterNoSpec : public IMaterial {
|
||||
public:
|
||||
static int32_t s_refCount;
|
||||
static CGxShader* s_vertexShaders[4];
|
||||
static CGxShader* s_pixelShader;
|
||||
|
||||
static CMaterialWaterNoSpec* Create();
|
||||
|
||||
virtual ~CMaterialWaterNoSpec();
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
|
||||
CMaterialWaterNoSpec();
|
||||
};
|
||||
|
||||
class CMaterialWaterFFP : public IMaterial {
|
||||
public:
|
||||
static CMaterialWaterFFP* Create();
|
||||
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
};
|
||||
|
||||
class CMaterialMagma : public IMaterial {
|
||||
public:
|
||||
static int32_t s_refCount;
|
||||
static CGxShader* s_vertexShader;
|
||||
static CGxShader* s_pixelShader;
|
||||
|
||||
static CMaterialMagma* Create();
|
||||
|
||||
virtual ~CMaterialMagma();
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
|
||||
CMaterialMagma();
|
||||
};
|
||||
|
||||
class CMaterialMagmaFFP : public IMaterial {
|
||||
public:
|
||||
static CMaterialMagmaFFP* Create();
|
||||
|
||||
virtual void Release();
|
||||
virtual void Render(IEnvironment* environment, IGeomFactory* geomFactory, IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, CMaterialSettings* settings);
|
||||
};
|
||||
|
||||
class IVertexData {
|
||||
public:
|
||||
/* 0004 */ uint32_t unk_0004;
|
||||
|
||||
virtual ~IVertexData();
|
||||
virtual float GetHeight(uint32_t index) = 0;
|
||||
virtual uint8_t GetDepth(uint32_t index) = 0;
|
||||
virtual const uint16_t* GetTexCoord(uint32_t index) = 0;
|
||||
};
|
||||
|
||||
class CChunkVertexData : public IVertexData {
|
||||
public:
|
||||
/* 0008 */ const uint8_t* m_data;
|
||||
/* 000C */ uint32_t m_format;
|
||||
|
||||
virtual float GetHeight(uint32_t index);
|
||||
virtual uint8_t GetDepth(uint32_t index);
|
||||
virtual const uint16_t* GetTexCoord(uint32_t index);
|
||||
|
||||
CChunkVertexData(const uint8_t* data, uint32_t format);
|
||||
};
|
||||
|
||||
class CAreaData;
|
||||
|
||||
class CInstanceVertexData : public IVertexData {
|
||||
public:
|
||||
/* 0008 */ const uint8_t* m_data;
|
||||
/* 000C */ const SMLiquidInstance* m_instance;
|
||||
/* 0010 */ uint32_t m_vertexCount;
|
||||
|
||||
virtual float GetHeight(uint32_t index);
|
||||
virtual uint8_t GetDepth(uint32_t index);
|
||||
virtual const uint16_t* GetTexCoord(uint32_t index);
|
||||
|
||||
CInstanceVertexData(const CAreaData* areaData, const SMLiquidInstance* instance);
|
||||
};
|
||||
|
||||
class CAreaData {
|
||||
public:
|
||||
static uint8_t s_emptyTable[8];
|
||||
static uint8_t s_fullTable[8];
|
||||
static uint16_t s_defaultTexCoord[2];
|
||||
|
||||
/* 0000 */ uint32_t unk_0000;
|
||||
/* 0004 */ const uint8_t* m_data;
|
||||
|
||||
CAreaData(const void* data);
|
||||
void SetData(const void* data);
|
||||
bool HasData() const;
|
||||
const SMLiquidChunkDesc* GetChunkDesc(uint32_t x, uint32_t y) const;
|
||||
const SMLiquidInstance* GetInstanceDesc(const SMLiquidChunkDesc* chunk, uint32_t index) const;
|
||||
const uint8_t* GetFishableTable(const SMLiquidChunkDesc* chunk) const;
|
||||
const uint8_t* GetDeepTable(const SMLiquidChunkDesc* chunk) const;
|
||||
const uint8_t* GetExistsTable(const SMLiquidInstance* instance) const;
|
||||
};
|
||||
|
||||
class CMaterialSettings {
|
||||
public:
|
||||
/* 0000 */ char m_textureNames[6][128];
|
||||
/* 0300 */ CImVector m_colors[2];
|
||||
/* 0308 */ int32_t m_ints[4];
|
||||
/* 0318 */ float m_floats[18];
|
||||
/* 0360 */ int32_t m_transparent;
|
||||
/* 0364 */ int32_t m_texturesReady[6];
|
||||
/* 037C */ TSGrowableArray<CTexture*> m_textures[6];
|
||||
/* 03DC */ TSGrowableArray<CTexture*> m_pendingTextures[6];
|
||||
|
||||
CMaterialSettings();
|
||||
~CMaterialSettings();
|
||||
void Destroy();
|
||||
float GetFloat(uint32_t index) const;
|
||||
int32_t GetInt(uint32_t index) const;
|
||||
CGxTex* GetTexture(uint32_t index, uint32_t period);
|
||||
void InitTexture();
|
||||
};
|
||||
|
||||
class CInstance {
|
||||
public:
|
||||
static CInstance* Create();
|
||||
|
||||
/* 0000 */ IMaterial* m_material;
|
||||
/* 0004 */ CMaterialSettings* m_settings;
|
||||
/* 0008 */ IGeomFactory* m_geomFactory;
|
||||
/* 000C */ IWaveManager* m_waveManager;
|
||||
/* 0010 */ IEnvironment* m_environment;
|
||||
/* 0014 */ C44Matrix m_transform;
|
||||
/* 0054 */ CAaSphere m_bounds;
|
||||
/* 0064 */ int32_t m_queued;
|
||||
/* 0068 */ int32_t m_refCount;
|
||||
|
||||
CInstance();
|
||||
void AddRef();
|
||||
void Purge();
|
||||
void Release();
|
||||
};
|
||||
|
||||
class CRenderer {
|
||||
public:
|
||||
typedef int32_t (*DrawListSorter)(const void* a, const void* b);
|
||||
|
||||
static DrawListSorter s_drawListSorter[2];
|
||||
|
||||
static int32_t CompareOpaque(const void* a, const void* b);
|
||||
static int32_t CompareTransparent(const void* a, const void* b);
|
||||
|
||||
/* 0000 */ TSGrowableArray<CInstance*> m_instances[2];
|
||||
|
||||
~CRenderer();
|
||||
void Draw(CInstance* instance);
|
||||
void Flush(const C3Vector& cameraPos, uint32_t pass);
|
||||
};
|
||||
|
||||
class CSettingsBank {
|
||||
public:
|
||||
static TSGrowableArray<CMaterialSettings*> s_settings;
|
||||
|
||||
static void Destroy();
|
||||
static CMaterialSettings* GetSettings(uint32_t liquidType);
|
||||
static void ResetTextures();
|
||||
static bool UpdateRecord(CMaterialSettings* settings, uint32_t liquidType);
|
||||
};
|
||||
|
||||
class CMaterialBank {
|
||||
public:
|
||||
static TSGrowableArray<IMaterial*> s_unk_D43B24;
|
||||
|
||||
static void Destroy();
|
||||
static IMaterial* GetMaterial(uint32_t liquidType);
|
||||
};
|
||||
|
||||
extern CDataAllocator s_unk_D43B00;
|
||||
extern CDataAllocator s_unk_D43B34;
|
||||
extern CDataAllocator s_unk_D45048;
|
||||
extern CDataAllocator s_unk_D4505C;
|
||||
extern CDataAllocator s_unk_D45070;
|
||||
extern CDataAllocator s_unk_D45084;
|
||||
extern CDataAllocator s_unk_D45098;
|
||||
extern CDataAllocator s_unk_D450AC;
|
||||
extern CDataAllocator s_unk_D450C0;
|
||||
extern float s_unk_B23F64;
|
||||
extern int32_t s_unk_B23F68;
|
||||
extern IDatabase<LiquidMaterialRec>* s_liquidMaterialDB;
|
||||
extern IDatabase<LiquidTypeRec>* s_liquidTypeDB;
|
||||
extern char s_unk_D439F0[256];
|
||||
extern int32_t s_unk_D43AF0;
|
||||
extern int32_t s_unk_D43AF4;
|
||||
extern int32_t s_unk_D43AF8;
|
||||
extern int32_t s_unk_D43AFC;
|
||||
extern uint8_t s_unk_D43B48[4];
|
||||
extern CTexture* s_unk_D43B4C;
|
||||
extern CTexture* s_unk_D43B50[32];
|
||||
extern CTexture* s_wmoWaterTex;
|
||||
extern CTexture* s_oceanDepthTex;
|
||||
extern CTexture* s_riverDepthTex;
|
||||
extern VSConstants s_vsConstants;
|
||||
extern VSWaveConstants s_vsWaveConstants;
|
||||
extern PSConstants s_psConstants;
|
||||
extern PSProcWaterConstants s_psProcWaterConstants;
|
||||
|
||||
void CacheProceduralTextures();
|
||||
void ClearMaterials();
|
||||
void CreateProceduralTextures();
|
||||
void DestroyProceduralTextures();
|
||||
void ExtWaterDepthTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
const char* GetShaderSuffix();
|
||||
C44Matrix* GetTexScrollMtx(const C2Vector& speed);
|
||||
int32_t Initialize(int32_t a1, float a2, int32_t a3, const char* a4, IDatabase<LiquidTypeRec>* liquidTypeDB, IDatabase<LiquidMaterialRec>* liquidMaterialDB);
|
||||
void InvalidateProceduralTextures();
|
||||
void SetCircularWave(uint32_t index, const C2Vector& a2, const C2Vector& a3, float a4, float a5, float a6, float speed);
|
||||
void SetDirectionalWave(uint32_t index, const C2Vector& direction, float a3, float a4, float a5, float speed);
|
||||
void SetProcWaterLighting(const CM2Lighting& lighting);
|
||||
void SetProcWaterParams(float a1, float a2, float a3, float a4, float a5, float a6, float a7);
|
||||
void SetShaderConstants();
|
||||
void SetShaderLighting(const CM2Lighting& lighting);
|
||||
void SetShaderTransforms(const C3Vector& cameraPos, const C44Matrix& transform);
|
||||
void Shutdown();
|
||||
void UpdateProceduralTextures();
|
||||
int32_t UseCameraRelativeCoords();
|
||||
void WmoWaterTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
float WorldCoordScale();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
#include "Liquid.h"
|
||||
|
||||
// STATIC: 0x00A59484
|
||||
uint8_t Liquid::CAreaData::s_emptyTable[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
// STATIC: 0x00A5948C
|
||||
uint8_t Liquid::CAreaData::s_fullTable[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
// STATIC: 0x00A59494
|
||||
uint16_t Liquid::CAreaData::s_defaultTexCoord[2] = { 0, 0 };
|
||||
|
||||
// VERIFY: b3a3de07 auto
|
||||
// OFFSET: 0x007D4F10
|
||||
void Liquid::CAreaData::SetData(const void* data) {
|
||||
this->m_data = static_cast<const uint8_t*>(data);
|
||||
}
|
||||
|
||||
// VERIFY: b03625ac auto
|
||||
// OFFSET: 0x008A3050
|
||||
Liquid::CAreaData::CAreaData(const void* data) {
|
||||
this->m_data = static_cast<const uint8_t*>(data);
|
||||
}
|
||||
|
||||
// VERIFY: 71cd1ec5 manual
|
||||
// OFFSET: 0x008A3060
|
||||
bool Liquid::CAreaData::HasData() const {
|
||||
return this->m_data != nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 6ee106da auto
|
||||
// OFFSET: 0x008A3070
|
||||
const SMLiquidChunkDesc* Liquid::CAreaData::GetChunkDesc(uint32_t x, uint32_t y) const {
|
||||
return reinterpret_cast<const SMLiquidChunkDesc*>(this->m_data) + (x + 16 * y);
|
||||
}
|
||||
|
||||
// VERIFY: f4b46567 auto
|
||||
// OFFSET: 0x008A3090
|
||||
const SMLiquidInstance* Liquid::CAreaData::GetInstanceDesc(const SMLiquidChunkDesc* chunk, uint32_t index) const {
|
||||
return reinterpret_cast<const SMLiquidInstance*>(this->m_data + chunk->m_offsetInstances) + index;
|
||||
}
|
||||
|
||||
// VERIFY: 6e52450a auto
|
||||
// OFFSET: 0x008A30B0
|
||||
const uint8_t* Liquid::CAreaData::GetFishableTable(const SMLiquidChunkDesc* chunk) const {
|
||||
if (!chunk->m_layerCount) {
|
||||
return Liquid::CAreaData::s_emptyTable;
|
||||
}
|
||||
|
||||
if (chunk->m_offsetAttributes) {
|
||||
return this->m_data + chunk->m_offsetAttributes;
|
||||
}
|
||||
|
||||
return Liquid::CAreaData::s_fullTable;
|
||||
}
|
||||
|
||||
// VERIFY: 3dff8387 auto
|
||||
// OFFSET: 0x008A30E0
|
||||
const uint8_t* Liquid::CAreaData::GetDeepTable(const SMLiquidChunkDesc* chunk) const {
|
||||
if (!chunk->m_layerCount) {
|
||||
return Liquid::CAreaData::s_emptyTable;
|
||||
}
|
||||
|
||||
if (chunk->m_offsetAttributes) {
|
||||
return this->m_data + chunk->m_offsetAttributes + 8;
|
||||
}
|
||||
|
||||
return Liquid::CAreaData::s_fullTable;
|
||||
}
|
||||
|
||||
// VERIFY: 6b0d6dd8 manual
|
||||
// OFFSET: 0x008A3110
|
||||
const uint8_t* Liquid::CAreaData::GetExistsTable(const SMLiquidInstance* instance) const {
|
||||
if (instance->m_offsetExistsBitmap) {
|
||||
return this->m_data + instance->m_offsetExistsBitmap;
|
||||
}
|
||||
|
||||
return Liquid::CAreaData::s_fullTable;
|
||||
}
|
||||
|
||||
// VERIFY: 0ecbc03f manual
|
||||
// OFFSET: 0x008A3130
|
||||
float Liquid::CInstanceVertexData::GetHeight(uint32_t index) {
|
||||
if (this->m_instance->m_vertexFormat > 1) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return reinterpret_cast<const float*>(this->m_data + this->m_instance->m_offsetVertexData)[index];
|
||||
}
|
||||
|
||||
// VERIFY: 43850342 manual
|
||||
// OFFSET: 0x008A3160
|
||||
uint8_t Liquid::CInstanceVertexData::GetDepth(uint32_t index) {
|
||||
const SMLiquidInstance* instance = this->m_instance;
|
||||
|
||||
if (instance->m_vertexFormat == 0) {
|
||||
return (this->m_data + instance->m_offsetVertexData + 4 * this->m_vertexCount)[index];
|
||||
}
|
||||
|
||||
if (instance->m_vertexFormat != 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (instance->m_offsetVertexData) {
|
||||
return (this->m_data + instance->m_offsetVertexData)[index];
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
// VERIFY: 5fa5f4f8 manual
|
||||
// OFFSET: 0x008A31B0
|
||||
const uint16_t* Liquid::CInstanceVertexData::GetTexCoord(uint32_t index) {
|
||||
if (this->m_instance->m_vertexFormat == 1) {
|
||||
return reinterpret_cast<const uint16_t*>(this->m_data + this->m_instance->m_offsetVertexData + 4 * (index + this->m_vertexCount));
|
||||
}
|
||||
|
||||
return Liquid::CAreaData::s_defaultTexCoord;
|
||||
}
|
||||
|
||||
// VERIFY: 7b8fdcd4 auto
|
||||
// OFFSET: 0x008A31E0
|
||||
Liquid::CChunkVertexData::CChunkVertexData(const uint8_t* data, uint32_t format) {
|
||||
this->m_data = data;
|
||||
this->m_format = format;
|
||||
}
|
||||
|
||||
// VERIFY: 9dcee70a manual
|
||||
// OFFSET: 0x008A3200
|
||||
float Liquid::CChunkVertexData::GetHeight(uint32_t index) {
|
||||
if (this->m_format > 1) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return *reinterpret_cast<const float*>(this->m_data + 8 * index + 4);
|
||||
}
|
||||
|
||||
// VERIFY: 0121d633 manual
|
||||
// OFFSET: 0x008A3220
|
||||
uint8_t Liquid::CChunkVertexData::GetDepth(uint32_t index) {
|
||||
uint32_t format = this->m_format;
|
||||
|
||||
if (format == 0 || format == 2) {
|
||||
return this->m_data[8 * index];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// VERIFY: 681ed984 manual
|
||||
// OFFSET: 0x008A3250
|
||||
const uint16_t* Liquid::CChunkVertexData::GetTexCoord(uint32_t index) {
|
||||
if (this->m_format == 1) {
|
||||
return reinterpret_cast<const uint16_t*>(this->m_data + 8 * index);
|
||||
}
|
||||
|
||||
return Liquid::CAreaData::s_defaultTexCoord;
|
||||
}
|
||||
|
||||
// VERIFY: 3d77147d auto
|
||||
// OFFSET: 0x008A3280
|
||||
Liquid::CInstanceVertexData::CInstanceVertexData(const Liquid::CAreaData* areaData, const SMLiquidInstance* instance) {
|
||||
this->m_data = areaData->m_data;
|
||||
this->m_instance = instance;
|
||||
this->m_vertexCount = (instance->m_width + 1) * (instance->m_height + 1);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Os/TimeManager.h"
|
||||
#include "Engine/Source/ShaderEffect/ShaderEffect.h"
|
||||
#include "Engine/Source/Tempest/C33Matrix.h"
|
||||
|
||||
// STATIC: 0x00D44CA8
|
||||
Liquid::VSConstants Liquid::s_vsConstants;
|
||||
|
||||
// STATIC: 0x00B24120
|
||||
Liquid::PSConstants Liquid::s_psConstants;
|
||||
|
||||
// VERIFY: ea58aa9f manual
|
||||
// OFFSET: 0x008A32F0
|
||||
void Liquid::SetShaderTransforms(const C3Vector& cameraPos, const C44Matrix& transform) {
|
||||
C44Matrix view;
|
||||
GxXformView(view);
|
||||
|
||||
C44Matrix world = transform;
|
||||
|
||||
if (Liquid::UseCameraRelativeCoords()) {
|
||||
world.d0 -= cameraPos.x;
|
||||
world.d1 -= cameraPos.y;
|
||||
world.d2 -= cameraPos.z;
|
||||
}
|
||||
|
||||
C44Matrix modelView = world * view;
|
||||
Liquid::s_vsConstants.m_modelView = modelView;
|
||||
|
||||
C44Matrix projection;
|
||||
projection = g_theGxDevicePtr->m_projNative;
|
||||
|
||||
if (g_theGxDevicePtr->DeviceApi() == GxApi_OpenGl) {
|
||||
projection.c0 *= -1.0f;
|
||||
projection.c1 *= -1.0f;
|
||||
projection.c2 *= -1.0f;
|
||||
projection.c3 *= -1.0f;
|
||||
}
|
||||
|
||||
Liquid::s_psConstants.m_modelViewProj = modelView * projection;
|
||||
Liquid::s_psConstants.m_cameraPos.x = cameraPos.x;
|
||||
Liquid::s_psConstants.m_cameraPos.y = cameraPos.y;
|
||||
Liquid::s_psConstants.m_cameraPos.z = cameraPos.z;
|
||||
Liquid::s_psConstants.m_cameraPos.w = 1.0f;
|
||||
}
|
||||
|
||||
// VERIFY: ab5711b4 manual
|
||||
// OFFSET: 0x008A34B0
|
||||
C44Matrix* Liquid::GetTexScrollMtx(const C2Vector& speed) {
|
||||
float u = 0.0f;
|
||||
float v = 0.0f;
|
||||
uint32_t time = OsGetAsyncTimeMs();
|
||||
|
||||
if (speed.x != 0.0f) {
|
||||
uint32_t period = static_cast<uint32_t>(1000.0f / speed.x);
|
||||
u = static_cast<float>(time % period) / static_cast<float>(period);
|
||||
}
|
||||
|
||||
if (speed.y != 0.0f) {
|
||||
uint32_t period = static_cast<uint32_t>(1000.0f / speed.y);
|
||||
v = static_cast<float>(time % period) / static_cast<float>(period);
|
||||
}
|
||||
|
||||
// STATIC: 0x00D450D8
|
||||
static C44Matrix s_matrix;
|
||||
|
||||
s_matrix.d0 = u;
|
||||
s_matrix.d1 = v;
|
||||
s_matrix.d2 = 0.0f;
|
||||
|
||||
return &s_matrix;
|
||||
}
|
||||
|
||||
// VERIFY: 0ef940ce manual
|
||||
// OFFSET: 0x008A38B0
|
||||
void Liquid::SetShaderLighting(const CM2Lighting& lighting) {
|
||||
C44Matrix view;
|
||||
GxXformView(view);
|
||||
|
||||
C3Vector sunDir = lighting.m_sunDir * C33Matrix(view);
|
||||
Liquid::s_vsConstants.m_sunDir.x = sunDir.x;
|
||||
Liquid::s_vsConstants.m_sunDir.y = sunDir.y;
|
||||
Liquid::s_vsConstants.m_sunDir.z = sunDir.z;
|
||||
Liquid::s_vsConstants.m_sunDir.w = 1.0f;
|
||||
|
||||
Liquid::s_vsConstants.m_sunAmbient.x = lighting.m_sunAmbient.x;
|
||||
Liquid::s_vsConstants.m_sunAmbient.y = lighting.m_sunAmbient.y;
|
||||
Liquid::s_vsConstants.m_sunAmbient.z = lighting.m_sunAmbient.z;
|
||||
Liquid::s_vsConstants.m_sunAmbient.w = 1.0f;
|
||||
|
||||
Liquid::s_vsConstants.m_sunDiffuse.x = lighting.m_sunDiffuse.x;
|
||||
Liquid::s_vsConstants.m_sunDiffuse.y = lighting.m_sunDiffuse.y;
|
||||
Liquid::s_vsConstants.m_sunDiffuse.z = lighting.m_sunDiffuse.z;
|
||||
Liquid::s_vsConstants.m_sunDiffuse.w = 1.0f;
|
||||
|
||||
Liquid::s_vsConstants.m_sunSpecular.x = lighting.m_sunSpecular.x;
|
||||
Liquid::s_vsConstants.m_sunSpecular.y = lighting.m_sunSpecular.y;
|
||||
Liquid::s_vsConstants.m_sunSpecular.z = lighting.m_sunSpecular.z;
|
||||
Liquid::s_vsConstants.m_sunSpecular.w = 6.0f;
|
||||
|
||||
uint32_t lightCount = lighting.m_lightCount;
|
||||
|
||||
for (uint32_t i = 0; i < lightCount; i++) {
|
||||
if (i >= sizeof(Liquid::s_vsConstants.m_lights) / sizeof(Liquid::s_vsConstants.m_lights[0])) {
|
||||
break;
|
||||
}
|
||||
|
||||
const CM2Light* light = lighting.m_lights[i];
|
||||
C3Vector position = light->m_pos * C33Matrix(view);
|
||||
Liquid::VSLight& constants = Liquid::s_vsConstants.m_lights[i];
|
||||
|
||||
constants.m_position.x = position.x;
|
||||
constants.m_position.y = position.y;
|
||||
constants.m_position.z = position.z;
|
||||
constants.m_position.w = 1.0f;
|
||||
|
||||
constants.m_color.x = light->m_dirColor.x * (1.0f / 255.0f);
|
||||
constants.m_color.y = light->m_dirColor.y * (1.0f / 255.0f);
|
||||
constants.m_color.z = light->m_dirColor.z * (1.0f / 255.0f);
|
||||
constants.m_color.w = 1.0f;
|
||||
|
||||
constants.m_attenuation.x = light->m_constantAttenuation;
|
||||
constants.m_attenuation.y = light->m_linearAttenuation;
|
||||
constants.m_attenuation.z = light->m_quadraticAttenuation;
|
||||
}
|
||||
|
||||
if (g_theGxDevicePtr->MasterEnable(GxMasterEnable_Fog)) {
|
||||
float fogEnd = lighting.m_fogEnd;
|
||||
float fogRange = 1.0f / (fogEnd - lighting.m_fogStart);
|
||||
Liquid::s_vsConstants.m_fog.x = -(fogRange * CShaderEffect::s_fogMul);
|
||||
Liquid::s_vsConstants.m_fog.y = fogEnd * fogRange;
|
||||
Liquid::s_vsConstants.m_fog.z = lighting.m_fogDensity;
|
||||
Liquid::s_vsConstants.m_fog.w = 0.0f;
|
||||
} else {
|
||||
Liquid::s_vsConstants.m_fog.x = 0.0f;
|
||||
Liquid::s_vsConstants.m_fog.y = 1.0f;
|
||||
Liquid::s_vsConstants.m_fog.z = 1.0f;
|
||||
Liquid::s_vsConstants.m_fog.w = 0.0f;
|
||||
}
|
||||
|
||||
Liquid::s_psConstants.m_fogColor.x = lighting.m_fogColor.x;
|
||||
Liquid::s_psConstants.m_fogColor.y = lighting.m_fogColor.y;
|
||||
Liquid::s_psConstants.m_fogColor.z = lighting.m_fogColor.z;
|
||||
Liquid::s_psConstants.m_fogColor.w = 1.0f;
|
||||
}
|
||||
|
||||
// VERIFY: e12a4641 auto
|
||||
// OFFSET: 0x008A3DA0
|
||||
void Liquid::SetShaderConstants() {
|
||||
g_theGxDevicePtr->ShaderConstantsSet(GxSh_Vertex, 0, reinterpret_cast<const float*>(&Liquid::s_vsConstants), 46);
|
||||
g_theGxDevicePtr->ShaderConstantsSet(GxSh_Pixel, 0, reinterpret_cast<const float*>(&Liquid::s_psConstants), 6);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Services/SysMessage.h"
|
||||
#include "WoW/Source/DB/WowClientDB.h"
|
||||
#include "WoW/Source/DB/Rec/LiquidTypeRec.h"
|
||||
|
||||
// STATIC: 0x00D43B24
|
||||
TSGrowableArray<Liquid::IMaterial*> Liquid::CMaterialBank::s_unk_D43B24;
|
||||
|
||||
// VERIFY: 44d8beb7 manual
|
||||
// OFFSET: 0x008A1F50
|
||||
void Liquid::CMaterialBank::Destroy() {
|
||||
for (uint32_t i = 0; i < Liquid::CMaterialBank::s_unk_D43B24.Count(); i++) {
|
||||
if (Liquid::CMaterialBank::s_unk_D43B24[i]) {
|
||||
Liquid::CMaterialBank::s_unk_D43B24[i]->Release();
|
||||
}
|
||||
}
|
||||
|
||||
Liquid::CMaterialBank::s_unk_D43B24.SetCount(0);
|
||||
}
|
||||
|
||||
// VERIFY: 502f2f3f auto
|
||||
// OFFSET: 0x008A4280
|
||||
void Liquid::ClearMaterials() {
|
||||
Liquid::s_unk_D45048.Clear(".?AVCMaterialProcWater@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D4505C.Clear(".?AVCMaterialProcWaterFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45070.Clear(".?AVCMaterialWater@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45084.Clear(".?AVCMaterialWaterNoSpec@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45098.Clear(".?AVCMaterialWaterFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D450AC.Clear(".?AVCMaterialMagma@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D450C0.Clear(".?AVCMaterialMagmaFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: e742ff22 auto
|
||||
// OFFSET: 0x008A1FA0
|
||||
Liquid::IMaterial* Liquid::CMaterialBank::GetMaterial(uint32_t liquidType) {
|
||||
LiquidTypeRec* typeRec;
|
||||
|
||||
while (true) {
|
||||
if (!Liquid::s_unk_D43AFC) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
typeRec = Liquid::s_liquidTypeDB->GetRecord(liquidType);
|
||||
|
||||
if (typeRec) {
|
||||
break;
|
||||
}
|
||||
|
||||
SysMsgPrintf(STATUS_ERROR, 2, "Material Bank: Liquid type [%d] not found, defaulting to water!", liquidType);
|
||||
liquidType = 1;
|
||||
}
|
||||
|
||||
uint32_t materialId = typeRec->m_materialID;
|
||||
|
||||
if (materialId < Liquid::CMaterialBank::s_unk_D43B24.Count() && Liquid::CMaterialBank::s_unk_D43B24.m_data[materialId]) {
|
||||
return Liquid::CMaterialBank::s_unk_D43B24.m_data[materialId];
|
||||
}
|
||||
|
||||
bool vertexShaders = g_theGxDevicePtr->Caps().m_shaderTargets[GxSh_Vertex] >= 1;
|
||||
bool shaders = Liquid::s_unk_D43AF0 && vertexShaders && g_theGxDevicePtr->Caps().m_shaderTargets[GxSh_Pixel] >= 3;
|
||||
|
||||
Liquid::IMaterial* material = nullptr;
|
||||
|
||||
switch (materialId) {
|
||||
case 1:
|
||||
if (shaders) {
|
||||
if (Liquid::s_unk_B23F68) {
|
||||
material = Liquid::CMaterialWater::Create();
|
||||
} else {
|
||||
material = Liquid::CMaterialWaterNoSpec::Create();
|
||||
}
|
||||
} else {
|
||||
material = Liquid::CMaterialWaterFFP::Create();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (shaders) {
|
||||
material = Liquid::CMaterialMagma::Create();
|
||||
} else {
|
||||
material = Liquid::CMaterialMagmaFFP::Create();
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (shaders) {
|
||||
material = Liquid::CMaterialProcWater::Create();
|
||||
} else {
|
||||
material = Liquid::CMaterialProcWaterFFP::Create();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Liquid::CMaterialBank::s_unk_D43B24.SetCount(materialId + 1);
|
||||
Liquid::CMaterialBank::s_unk_D43B24.m_data[materialId] = material;
|
||||
|
||||
return material;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Base/Handle.h"
|
||||
#include "Engine/Source/Base/Status.h"
|
||||
#include "Engine/Source/Gx/CGxTexFlags.h"
|
||||
#include "Engine/Source/Os/TimeManager.h"
|
||||
#include "Engine/Source/Services/Texture.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "Engine/Source/Tempest/CMath.h"
|
||||
|
||||
// VERIFY: c119ee84 auto
|
||||
// OFFSET: 0x008A16C0
|
||||
int32_t Liquid::CMaterialSettings::GetInt(uint32_t index) const {
|
||||
return this->m_ints[index];
|
||||
}
|
||||
|
||||
// VERIFY: 7e415766 auto
|
||||
// OFFSET: 0x008A16E0
|
||||
float Liquid::CMaterialSettings::GetFloat(uint32_t index) const {
|
||||
return this->m_floats[index];
|
||||
}
|
||||
|
||||
// VERIFY: 64d572f1 manual
|
||||
// OFFSET: 0x008A1C90
|
||||
Liquid::CMaterialSettings::~CMaterialSettings() {
|
||||
}
|
||||
|
||||
// VERIFY: 0f1ff559 manual
|
||||
// OFFSET: 0x008A1D00
|
||||
void Liquid::CMaterialSettings::Destroy() {
|
||||
for (uint32_t i = 0; i < 6; i++) {
|
||||
for (uint32_t j = 0; j < this->m_textures[i].Count(); j++) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(this->m_textures[i].m_data[j]));
|
||||
}
|
||||
|
||||
this->m_textures[i].m_count = 0;
|
||||
|
||||
for (uint32_t j = 0; j < this->m_pendingTextures[i].Count(); j++) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(this->m_pendingTextures[i].m_data[j]));
|
||||
}
|
||||
|
||||
this->m_pendingTextures[i].m_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: d9c082b2 manual
|
||||
// OFFSET: 0x008A1D60
|
||||
CGxTex* Liquid::CMaterialSettings::GetTexture(uint32_t index, uint32_t period) {
|
||||
TSGrowableArray<CTexture*>* textures = &this->m_textures[index];
|
||||
uint32_t count = textures->Count();
|
||||
|
||||
if (!count) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
return TextureGetGxTex(textures->m_data[0], 0, nullptr);
|
||||
}
|
||||
|
||||
if (!this->m_texturesReady[index]) {
|
||||
TSGrowableArray<CTexture*>* pending = &this->m_pendingTextures[index];
|
||||
|
||||
if (pending->Count()) {
|
||||
bool ready = true;
|
||||
|
||||
for (uint32_t i = 0; i < count && ready; i++) {
|
||||
CTexture* texture = textures->m_data[i];
|
||||
|
||||
if (TextureIsBlob(texture)) {
|
||||
TextureIncreasePriority(texture);
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
this->m_texturesReady[index] = 1;
|
||||
|
||||
for (uint32_t i = 0; i < pending->Count(); i++) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(pending->m_data[i]));
|
||||
}
|
||||
|
||||
pending->m_count = 0;
|
||||
} else {
|
||||
textures = pending;
|
||||
}
|
||||
} else {
|
||||
bool loaded = true;
|
||||
|
||||
for (uint32_t i = 0; i < count && loaded; i++) {
|
||||
if (!TextureGetGxTex(textures->m_data[i], 0, nullptr)) {
|
||||
loaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->m_texturesReady[index] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!period) {
|
||||
period = 1;
|
||||
}
|
||||
|
||||
float frame = static_cast<float>(OsGetAsyncTimeMs() % period) / static_cast<float>(period) * static_cast<float>(count);
|
||||
|
||||
return TextureGetGxTex(textures->m_data[CMath::fint_(frame - 0.5f)], 1, nullptr);
|
||||
}
|
||||
|
||||
// VERIFY: 7226420f manual
|
||||
// OFFSET: 0x008A2100
|
||||
Liquid::CMaterialSettings::CMaterialSettings() {
|
||||
}
|
||||
|
||||
// VERIFY: d19ea806 manual
|
||||
// OFFSET: 0x008A2450
|
||||
void Liquid::CMaterialSettings::InitTexture() {
|
||||
for (uint32_t i = 0; i < 6; i++) {
|
||||
this->m_texturesReady[i] = 0;
|
||||
|
||||
const char* name = this->m_textureNames[i];
|
||||
|
||||
if (!name[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t procedural = SStrStrI(name, "procedural") != nullptr;
|
||||
CGxTexFlags flags(procedural ? GxTex_Linear : GxTex_LinearMipLinear, !procedural, !procedural, 0, 0, 0, 1, 0, 0, 0);
|
||||
bool animated = SStrStrI(name, "%d") != nullptr;
|
||||
CStatus status;
|
||||
|
||||
if (animated) {
|
||||
char fileName[128];
|
||||
int32_t hasBlob = 0;
|
||||
|
||||
for (uint32_t frame = 1; frame <= 30; frame++) {
|
||||
SStrPrintf(fileName, sizeof(fileName), name, frame);
|
||||
CTexture* texture = TextureCreate(fileName, flags, &status, 0);
|
||||
this->m_textures[i].New(texture);
|
||||
|
||||
if (TextureIsBlob(texture)) {
|
||||
hasBlob = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasBlob) {
|
||||
for (uint32_t frame = 1; frame <= 30; frame++) {
|
||||
SStrPrintf(fileName, sizeof(fileName), name, frame);
|
||||
CTexture* texture = TextureCreateBlob(fileName, flags, &status, 1);
|
||||
|
||||
if (texture) {
|
||||
this->m_pendingTextures[i].New(texture);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_pendingTextures[i].Count() != this->m_textures[i].Count()) {
|
||||
for (uint32_t j = 0; j < this->m_pendingTextures[i].Count(); j++) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(this->m_pendingTextures[i].m_data[j]));
|
||||
}
|
||||
|
||||
this->m_pendingTextures[i].m_count = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CTexture* texture;
|
||||
|
||||
if (procedural) {
|
||||
texture = TextureCacheGetTexture(name);
|
||||
|
||||
if (!texture) {
|
||||
CImVector color;
|
||||
color.b = 0x00;
|
||||
color.g = 0xFF;
|
||||
color.r = 0x00;
|
||||
color.a = 0xFF;
|
||||
texture = TextureCreateSolid(color);
|
||||
}
|
||||
} else {
|
||||
texture = TextureCreate(name, flags, &status, 0);
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
this->m_textures[i].New(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Base/Handle.h"
|
||||
#include "Engine/Source/Gx/CGxTexFlags.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Services/Texture.h"
|
||||
#include "Engine/Source/Tempest/CiRect.h"
|
||||
#include "Engine/Source/Tempest/CMath.h"
|
||||
#include "Engine/Source/Tempest/NTempest.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
|
||||
// STATIC: 0x00D43B48
|
||||
uint8_t Liquid::s_unk_D43B48[4];
|
||||
|
||||
// STATIC: 0x00D43B4C
|
||||
CTexture* Liquid::s_unk_D43B4C;
|
||||
|
||||
// STATIC: 0x00D43B50
|
||||
CTexture* Liquid::s_unk_D43B50[32];
|
||||
|
||||
// STATIC: 0x00D43BD0
|
||||
CTexture* Liquid::s_wmoWaterTex;
|
||||
|
||||
// STATIC: 0x00D43BD4
|
||||
CTexture* Liquid::s_oceanDepthTex;
|
||||
|
||||
// STATIC: 0x00D43BD8
|
||||
CTexture* Liquid::s_riverDepthTex;
|
||||
|
||||
// VERIFY: 901024cc manual
|
||||
// OFFSET: 0x008A2980
|
||||
void Liquid::DestroyProceduralTextures() {
|
||||
if (Liquid::s_unk_D43B4C) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_unk_D43B4C));
|
||||
Liquid::s_unk_D43B4C = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_riverDepthTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_riverDepthTex));
|
||||
Liquid::s_riverDepthTex = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_oceanDepthTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_oceanDepthTex));
|
||||
Liquid::s_oceanDepthTex = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_wmoWaterTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_wmoWaterTex));
|
||||
Liquid::s_wmoWaterTex = nullptr;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(Liquid::s_unk_D43B50) / sizeof(Liquid::s_unk_D43B50[0]); i++) {
|
||||
if (Liquid::s_unk_D43B50[i]) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_unk_D43B50[i]));
|
||||
Liquid::s_unk_D43B50[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: bbba7190 auto
|
||||
// OFFSET: 0x008A2A10
|
||||
void Liquid::CacheProceduralTextures() {
|
||||
CGxTexFlags flags;
|
||||
|
||||
TextureCacheNewTexture(Liquid::s_riverDepthTex);
|
||||
TextureCacheNewTexture(Liquid::s_oceanDepthTex);
|
||||
TextureCacheNewTexture(Liquid::s_wmoWaterTex);
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(Liquid::s_unk_D43B50) / sizeof(Liquid::s_unk_D43B50[0]); i++) {
|
||||
if (Liquid::s_unk_D43B50[i]) {
|
||||
TextureCacheNewTexture(Liquid::s_unk_D43B50[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Liquid::s_unk_D43B4C) {
|
||||
TextureCacheNewTexture(Liquid::s_unk_D43B4C);
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::ResetTextures();
|
||||
}
|
||||
|
||||
// VERIFY: 5d576297 auto
|
||||
// OFFSET: 0x008A2E20
|
||||
void Liquid::CreateProceduralTextures() {
|
||||
Liquid::s_unk_D43B48[3] = 0;
|
||||
Liquid::s_unk_D43B48[2] = 0;
|
||||
Liquid::s_unk_D43B48[1] = 0;
|
||||
Liquid::s_unk_D43B48[0] = 0;
|
||||
|
||||
CGxTexFlags flags;
|
||||
Liquid::s_riverDepthTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, reinterpret_cast<void*>(1), Liquid::ExtWaterDepthTexCallback, "proceduralRiverDepthTex", 0);
|
||||
|
||||
flags = CGxTexFlags();
|
||||
Liquid::s_oceanDepthTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, nullptr, Liquid::ExtWaterDepthTexCallback, "proceduralOceanDepthTex", 0);
|
||||
|
||||
flags = CGxTexFlags();
|
||||
Liquid::s_wmoWaterTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, nullptr, Liquid::WmoWaterTexCallback, "proceduralWmoWaterTex", 0);
|
||||
|
||||
Liquid::CacheProceduralTextures();
|
||||
}
|
||||
|
||||
// VERIFY: 7e3d28c3 manual
|
||||
// OFFSET: 0x008A2F00
|
||||
void Liquid::UpdateProceduralTextures() {
|
||||
if (!Liquid::s_unk_D43B48[3] && Liquid::s_oceanDepthTex) {
|
||||
CGxTex* gxTex = TextureGetGxTex(Liquid::s_oceanDepthTex, 0, nullptr);
|
||||
|
||||
if (gxTex) {
|
||||
CiRect rect;
|
||||
rect.minY = 0;
|
||||
rect.minX = 0;
|
||||
rect.maxY = 64;
|
||||
rect.maxX = 8;
|
||||
GxTexUpdate(gxTex, rect, 0);
|
||||
Liquid::s_unk_D43B48[3] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Liquid::s_unk_D43B48[2] && Liquid::s_riverDepthTex) {
|
||||
CGxTex* gxTex = TextureGetGxTex(Liquid::s_riverDepthTex, 0, nullptr);
|
||||
|
||||
if (gxTex) {
|
||||
CiRect rect;
|
||||
rect.minY = 0;
|
||||
rect.minX = 0;
|
||||
rect.maxY = 64;
|
||||
rect.maxX = 8;
|
||||
GxTexUpdate(gxTex, rect, 0);
|
||||
Liquid::s_unk_D43B48[2] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Liquid::s_unk_D43B48[1] && Liquid::s_wmoWaterTex) {
|
||||
CGxTex* gxTex = TextureGetGxTex(Liquid::s_wmoWaterTex, 0, nullptr);
|
||||
|
||||
if (gxTex) {
|
||||
CiRect rect;
|
||||
rect.minY = 0;
|
||||
rect.minX = 0;
|
||||
rect.maxY = 64;
|
||||
rect.maxX = 8;
|
||||
GxTexUpdate(gxTex, rect, 0);
|
||||
Liquid::s_unk_D43B48[1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Liquid::s_unk_D43B48[0]) {
|
||||
for (uint32_t i = 0; i < sizeof(Liquid::s_unk_D43B50) / sizeof(Liquid::s_unk_D43B50[0]); i++) {
|
||||
if (Liquid::s_unk_D43B50[i]) {
|
||||
GxTexUpdate(TextureGetGxTex(Liquid::s_unk_D43B50[i], 0, nullptr), 0, 0, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Liquid::s_unk_D43B48[0] = 1;
|
||||
}
|
||||
|
||||
if (Liquid::s_unk_D43B4C) {
|
||||
CGxTex* gxTex = TextureGetGxTex(Liquid::s_unk_D43B4C, 1, nullptr);
|
||||
|
||||
if (gxTex) {
|
||||
GxTexStretch(gxTex, nullptr, nullptr, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: ff857bf4 auto
|
||||
// OFFSET: 0x008A2AA0
|
||||
void Liquid::InvalidateProceduralTextures() {
|
||||
Liquid::s_unk_D43B48[3] = 0;
|
||||
Liquid::s_unk_D43B48[2] = 0;
|
||||
Liquid::s_unk_D43B48[1] = 0;
|
||||
}
|
||||
|
||||
// VERIFY: 33364e6a manual
|
||||
// OFFSET: 0x008A2AC0
|
||||
void Liquid::WmoWaterTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels) {
|
||||
// STATIC: 0x00D43BE0
|
||||
static CImVector s_texels[64 * 8];
|
||||
|
||||
if (command != GxTex_Latch) {
|
||||
return;
|
||||
}
|
||||
|
||||
DayNight::DNInfo* info = DayNight::GetInfo();
|
||||
CImVector band = info->m_bands.m_band17;
|
||||
uint8_t shallowAlpha = CMath::fint_(info->m_bands.m_waterShallowAlpha * 255.0f);
|
||||
uint8_t deepAlpha = CMath::fint_(info->m_bands.m_waterDeepAlpha * 255.0f);
|
||||
int32_t alphaStep = ((deepAlpha - shallowAlpha) << 8) >> 6;
|
||||
int32_t alpha = shallowAlpha << 8;
|
||||
|
||||
CImVector color;
|
||||
color.b = band.b;
|
||||
color.g = band.g;
|
||||
color.r = band.r;
|
||||
|
||||
CImVector white;
|
||||
white.b = 0xFF;
|
||||
white.g = 0xFF;
|
||||
white.r = 0xFF;
|
||||
|
||||
for (uint32_t y = 0; y < 64; y++) {
|
||||
for (uint32_t x = 0; x < 4; x++) {
|
||||
color.a = alpha >> 8;
|
||||
s_texels[y * 8 + x] = color;
|
||||
}
|
||||
|
||||
for (uint32_t x = 4; x < 8; x++) {
|
||||
white.a = alpha >> 8;
|
||||
s_texels[y * 8 + x] = white;
|
||||
}
|
||||
|
||||
alpha += alphaStep;
|
||||
}
|
||||
|
||||
texelStrideInBytes = 8 * sizeof(CImVector);
|
||||
texels = s_texels;
|
||||
}
|
||||
|
||||
// VERIFY: e0acfc63 manual
|
||||
// OFFSET: 0x008A2BF0
|
||||
void Liquid::ExtWaterDepthTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels) {
|
||||
// STATIC: 0x00D443E8
|
||||
static CImVector s_texels[64 * 8];
|
||||
|
||||
if (command != GxTex_Latch) {
|
||||
return;
|
||||
}
|
||||
|
||||
DayNight::DNInfo* info = DayNight::GetInfo();
|
||||
|
||||
uint8_t shallowAlpha[2];
|
||||
shallowAlpha[0] = CMath::fint_(info->m_bands.m_oceanShallowAlpha * 255.0f);
|
||||
shallowAlpha[1] = CMath::fint_(info->m_bands.m_waterShallowAlpha * 255.0f);
|
||||
|
||||
uint8_t deepAlpha[2];
|
||||
deepAlpha[0] = CMath::fint_(info->m_bands.m_oceanDeepAlpha * 255.0f);
|
||||
deepAlpha[1] = CMath::fint_(info->m_bands.m_waterDeepAlpha * 255.0f);
|
||||
|
||||
uintptr_t type = reinterpret_cast<uintptr_t>(userArg);
|
||||
CImVector shallowColor = (&info->m_bands.m_band14)[type * 2];
|
||||
CImVector deepColor = (&info->m_bands.m_band15)[type * 2];
|
||||
|
||||
int32_t alphaStep = ((deepAlpha[type] - shallowAlpha[type]) << 8) >> 6;
|
||||
int32_t redStep = ((deepColor.r - shallowColor.r) << 8) >> 6;
|
||||
int32_t blueStep = ((deepColor.b - shallowColor.b) << 8) >> 6;
|
||||
int32_t greenStep = ((deepColor.g - shallowColor.g) << 8) >> 6;
|
||||
|
||||
int32_t alpha = shallowAlpha[type] << 8;
|
||||
int32_t red = shallowColor.r << 8;
|
||||
int32_t green = shallowColor.g << 8;
|
||||
int32_t blue = shallowColor.b << 8;
|
||||
|
||||
CImVector* row = s_texels;
|
||||
|
||||
for (uint32_t y = 0; y < height; y++) {
|
||||
CImVector color;
|
||||
color.b = blue >> 8;
|
||||
color.g = green >> 8;
|
||||
color.r = red >> 8;
|
||||
color.a = alpha >> 8;
|
||||
|
||||
if (y == height - 1 && type == 0) {
|
||||
C3Vector rgb(color);
|
||||
C3Vector hsv;
|
||||
RGBtoHSV(rgb, hsv);
|
||||
hsv.z *= 0.9f;
|
||||
HSVtoRGB(hsv, rgb);
|
||||
color = rgb;
|
||||
}
|
||||
|
||||
for (uint32_t x = 0; x < width; x++) {
|
||||
row[x] = color;
|
||||
}
|
||||
|
||||
green += greenStep;
|
||||
blue += blueStep;
|
||||
alpha += alphaStep;
|
||||
red += redStep;
|
||||
row += width;
|
||||
}
|
||||
|
||||
texelStrideInBytes = width * sizeof(CImVector);
|
||||
texels = s_texels;
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#include "Liquid.h"
|
||||
#include <cstdlib>
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/CGxLight.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00B23F6C
|
||||
Liquid::CRenderer::DrawListSorter Liquid::CRenderer::s_drawListSorter[2] = {
|
||||
Liquid::CRenderer::CompareOpaque,
|
||||
Liquid::CRenderer::CompareTransparent
|
||||
};
|
||||
|
||||
// VERIFY: 3d910c8b manual
|
||||
// OFFSET: 0x00791910
|
||||
Liquid::CRenderer::~CRenderer() {
|
||||
}
|
||||
|
||||
// VERIFY: c8176254 manual
|
||||
// OFFSET: 0x008A1980
|
||||
int32_t Liquid::CRenderer::CompareOpaque(const void* a, const void* b) {
|
||||
const Liquid::CInstance* l = static_cast<const Liquid::CInstance*>(a);
|
||||
const Liquid::CInstance* r = static_cast<const Liquid::CInstance*>(b);
|
||||
|
||||
if (l->m_material < r->m_material) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_material > r->m_material) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_settings < r->m_settings) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_settings > r->m_settings) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_geomFactory < r->m_geomFactory) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_geomFactory > r->m_geomFactory) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_transform.d3 > r->m_transform.d3) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_transform.d3 < r->m_transform.d3) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// VERIFY: abfe3e46 manual
|
||||
// OFFSET: 0x008A19E0
|
||||
int32_t Liquid::CRenderer::CompareTransparent(const void* a, const void* b) {
|
||||
const Liquid::CInstance* l = static_cast<const Liquid::CInstance*>(a);
|
||||
const Liquid::CInstance* r = static_cast<const Liquid::CInstance*>(b);
|
||||
|
||||
if (l->m_material < r->m_material) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_material > r->m_material) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_settings < r->m_settings) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_settings > r->m_settings) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_geomFactory < r->m_geomFactory) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_geomFactory > r->m_geomFactory) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->m_transform.d3 > r->m_transform.d3) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l->m_transform.d3 < r->m_transform.d3) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// VERIFY: f6fe74d2 manual
|
||||
// OFFSET: 0x008A20C0
|
||||
void Liquid::CRenderer::Draw(Liquid::CInstance* instance) {
|
||||
if (!instance->m_queued) {
|
||||
this->m_instances[instance->m_settings->m_transparent != 0].New(instance);
|
||||
instance->m_queued = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: d17a0633 manual
|
||||
// OFFSET: 0x008A2240
|
||||
void Liquid::CRenderer::Flush(const C3Vector& cameraPos, uint32_t pass) {
|
||||
CGxLight lights[4];
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
g_theGxDevicePtr->Light(i, lights[i]);
|
||||
}
|
||||
|
||||
TSGrowableArray<Liquid::CInstance*>& instances = this->m_instances[pass];
|
||||
qsort(instances.m_data, instances.Count(), sizeof(Liquid::CInstance*), Liquid::CRenderer::s_drawListSorter[pass]);
|
||||
|
||||
uint32_t count = instances.Count();
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
Liquid::CInstance* instance = instances.m_data[i];
|
||||
instance->m_material->Render(instance->m_environment, instance->m_geomFactory, instance->m_waveManager, cameraPos, &instance->m_transform, &instance->m_bounds, instance->m_settings);
|
||||
instance->m_queued = 0;
|
||||
}
|
||||
|
||||
instances.Clear();
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (lights[i].m_flags & 0x1) {
|
||||
g_theGxDevicePtr->LightSet(i, lights[i], C3Vector(0.0f, 0.0f, 0.0f));
|
||||
g_theGxDevicePtr->LightEnable(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Services/SysMessage.h"
|
||||
#include "WoW/Source/DB/WowClientDB.h"
|
||||
#include "WoW/Source/DB/Rec/LiquidTypeRec.h"
|
||||
#include "WoW/Source/DB/Rec/LiquidMaterialRec.h"
|
||||
|
||||
// STATIC: 0x00D43B00
|
||||
CDataAllocator Liquid::s_unk_D43B00(0x43C, 0x20);
|
||||
|
||||
// STATIC: 0x00D43B14
|
||||
TSGrowableArray<Liquid::CMaterialSettings*> Liquid::CSettingsBank::s_settings;
|
||||
|
||||
// VERIFY: f4d601a2 manual
|
||||
// OFFSET: 0x008A2380
|
||||
void Liquid::CSettingsBank::Destroy() {
|
||||
if (!--Liquid::s_unk_D43AF8) {
|
||||
for (uint32_t i = 0; i < Liquid::CSettingsBank::s_settings.Count(); i++) {
|
||||
if (Liquid::CSettingsBank::s_settings[i]) {
|
||||
Liquid::CSettingsBank::s_settings[i]->Destroy();
|
||||
|
||||
Liquid::CMaterialSettings* settings = Liquid::CSettingsBank::s_settings[i];
|
||||
settings->~CMaterialSettings();
|
||||
Liquid::s_unk_D43B00.PutData(settings, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::s_settings.SetCount(0);
|
||||
}
|
||||
|
||||
Liquid::s_unk_D43B00.Clear(".?AVCMaterialSettings@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 2a7eaf1c manual
|
||||
// OFFSET: 0x008A2780
|
||||
void Liquid::CSettingsBank::ResetTextures() {
|
||||
for (uint32_t i = 0; i < Liquid::CSettingsBank::s_settings.Count(); i++) {
|
||||
if (Liquid::CSettingsBank::s_settings[i]) {
|
||||
Liquid::CSettingsBank::s_settings[i]->Destroy();
|
||||
Liquid::CSettingsBank::s_settings[i]->InitTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: b281ff61 manual
|
||||
// OFFSET: 0x008A27C0
|
||||
bool Liquid::CSettingsBank::UpdateRecord(Liquid::CMaterialSettings* settings, uint32_t liquidType) {
|
||||
settings->Destroy();
|
||||
|
||||
LiquidTypeRec* typeRec = Liquid::s_liquidTypeDB->GetRecord(liquidType);
|
||||
|
||||
if (!typeRec) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LiquidMaterialRec* materialRec = Liquid::s_liquidMaterialDB->GetRecord(typeRec->m_materialID);
|
||||
|
||||
if (!materialRec) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 6; i++) {
|
||||
const char* src = typeRec->m_texture[i];
|
||||
char* dst = settings->m_textureNames[i];
|
||||
|
||||
while ((*dst++ = *src++) != 0) {
|
||||
}
|
||||
}
|
||||
|
||||
settings->m_colors[0] = *reinterpret_cast<CImVector*>(&typeRec->m_color[0]);
|
||||
settings->m_colors[1] = *reinterpret_cast<CImVector*>(&typeRec->m_color[1]);
|
||||
settings->m_ints[0] = typeRec->m_int[0];
|
||||
settings->m_ints[1] = typeRec->m_int[1];
|
||||
settings->m_ints[2] = typeRec->m_int[2];
|
||||
settings->m_ints[3] = typeRec->m_int[3];
|
||||
|
||||
for (uint32_t i = 0; i < 18; i++) {
|
||||
settings->m_floats[i] = typeRec->m_float[i];
|
||||
}
|
||||
|
||||
settings->m_transparent = materialRec->m_flags & 0x1;
|
||||
settings->InitTexture();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// VERIFY: ff01b3c6 auto
|
||||
// OFFSET: 0x008A28F0
|
||||
Liquid::CMaterialSettings* Liquid::CSettingsBank::GetSettings(uint32_t liquidType) {
|
||||
Liquid::CMaterialSettings* settings;
|
||||
|
||||
while (true) {
|
||||
if (liquidType < Liquid::CSettingsBank::s_settings.Count() && Liquid::CSettingsBank::s_settings.m_data[liquidType]) {
|
||||
return Liquid::CSettingsBank::s_settings.m_data[liquidType];
|
||||
}
|
||||
|
||||
void* mem = Liquid::s_unk_D43B00.GetData(0, ".?AVCMaterialSettings@Liquid@@", SLOG_OBJECT);
|
||||
settings = mem ? new (mem) Liquid::CMaterialSettings() : nullptr;
|
||||
|
||||
if (Liquid::CSettingsBank::UpdateRecord(settings, liquidType)) {
|
||||
break;
|
||||
}
|
||||
|
||||
SysMsgPrintf(STATUS_ERROR, 2, "Settings Bank: Liquid type [%d] not found, defaulting to water!", liquidType);
|
||||
liquidType = 1;
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::s_settings.SetCount(liquidType + 1);
|
||||
Liquid::CSettingsBank::s_settings.m_data[liquidType] = settings;
|
||||
|
||||
return settings;
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00D450C0
|
||||
CDataAllocator Liquid::s_unk_D450C0(4, 8);
|
||||
|
||||
// STATIC: 0x00D450AC
|
||||
CDataAllocator Liquid::s_unk_D450AC(4, 8);
|
||||
|
||||
// STATIC: 0x00D44C40
|
||||
int32_t Liquid::CMaterialMagma::s_refCount;
|
||||
|
||||
// STATIC: 0x00D44BF4
|
||||
CGxShader* Liquid::CMaterialMagma::s_vertexShader;
|
||||
|
||||
// STATIC: 0x00D44BF0
|
||||
CGxShader* Liquid::CMaterialMagma::s_pixelShader;
|
||||
|
||||
// VERIFY: 83f1c351 auto
|
||||
// OFFSET: 0x008A4170
|
||||
void Liquid::CMaterialMagma::Release() {
|
||||
this->~CMaterialMagma();
|
||||
Liquid::s_unk_D450AC.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: a8322b3f auto
|
||||
// OFFSET: 0x008A4190
|
||||
Liquid::CMaterialMagma::CMaterialMagma() {
|
||||
if (Liquid::CMaterialMagma::s_refCount++ == 0) {
|
||||
g_theGxDevicePtr->ShaderCreate(&Liquid::CMaterialMagma::s_vertexShader, GxSh_Vertex, "Shaders\\Vertex", "vsLiquidMagma", 1);
|
||||
g_theGxDevicePtr->ShaderCreate(&Liquid::CMaterialMagma::s_pixelShader, GxSh_Pixel, "Shaders\\Pixel", "psLiquidMagma", 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 90d48f71 auto
|
||||
// OFFSET: 0x008A4200
|
||||
Liquid::CMaterialMagma::~CMaterialMagma() {
|
||||
if (Liquid::CMaterialMagma::s_refCount-- == 1) {
|
||||
if (Liquid::CMaterialMagma::s_vertexShader) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialMagma::s_vertexShader);
|
||||
}
|
||||
|
||||
if (Liquid::CMaterialMagma::s_pixelShader) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialMagma::s_pixelShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 3c4b9f03 auto
|
||||
// OFFSET: 0x008A4260
|
||||
void Liquid::CMaterialMagmaFFP::Release() {
|
||||
this->~CMaterialMagmaFFP();
|
||||
Liquid::s_unk_D450C0.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 49300414 auto
|
||||
// OFFSET: 0x008A4870
|
||||
Liquid::CMaterialMagma* Liquid::CMaterialMagma::Create() {
|
||||
void* mem = Liquid::s_unk_D450AC.GetData(0, ".?AVCMaterialMagma@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialMagma() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 7d417cc9 auto
|
||||
// OFFSET: 0x008A48D0
|
||||
Liquid::CMaterialMagmaFFP* Liquid::CMaterialMagmaFFP::Create() {
|
||||
void* mem = Liquid::s_unk_D450C0.GetData(0, ".?AVCMaterialMagmaFFP@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialMagmaFFP() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: b5c1ce43 manual
|
||||
// OFFSET: 0x008A6090
|
||||
void Liquid::CMaterialMagma::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture0 = settings->GetTexture(0, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Fog, 1);
|
||||
|
||||
Liquid::s_vsConstants.m_projection = g_theGxDevicePtr->m_projNative;
|
||||
|
||||
if (g_theGxDevicePtr->DeviceApi() == GxApi_OpenGl) {
|
||||
Liquid::s_vsConstants.m_projection.c0 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c1 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c2 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c3 *= -1.0f;
|
||||
}
|
||||
|
||||
C44Matrix matrix;
|
||||
Liquid::SetShaderTransforms(cameraPos, geomFactory->SetTransform(const_cast<C44Matrix*>(transform)) ? matrix : *transform);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
Liquid::SetShaderLighting(lighting);
|
||||
|
||||
C2Vector speed;
|
||||
speed.x = settings->GetFloat(0);
|
||||
speed.y = settings->GetFloat(1);
|
||||
C44Matrix texMatrix = *Liquid::GetTexScrollMtx(speed);
|
||||
texMatrix.Scale(Liquid::WorldCoordScale());
|
||||
Liquid::s_vsConstants.m_texTransforms[0] = texMatrix;
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
Liquid::SetShaderConstants();
|
||||
g_theGxDevicePtr->RsSet(GxRs_VertexShader, Liquid::CMaterialMagma::s_vertexShader);
|
||||
g_theGxDevicePtr->RsSet(GxRs_PixelShader, Liquid::CMaterialMagma::s_pixelShader);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PCT, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PCT);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
|
||||
// VERIFY: 35b378c5 manual
|
||||
// OFFSET: 0x008A6350
|
||||
void Liquid::CMaterialMagmaFFP::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture0 = settings->GetTexture(0, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->XformPush(GxXform_World);
|
||||
g_theGxDevicePtr->XformPush(GxXform_Tex0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
|
||||
C44Matrix world = *transform;
|
||||
|
||||
if (Liquid::UseCameraRelativeCoords()) {
|
||||
world.d0 -= cameraPos.x;
|
||||
world.d1 -= cameraPos.y;
|
||||
world.d2 -= cameraPos.z;
|
||||
}
|
||||
|
||||
GxXformSet(GxXform_World, world);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
lighting.SetupGxLights(&cameraPos);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Lighting, 0);
|
||||
lighting.SetupGxFog();
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
|
||||
C2Vector speed;
|
||||
speed.x = settings->GetFloat(0);
|
||||
speed.y = settings->GetFloat(1);
|
||||
GxXformSet(GxXform_Tex0, *Liquid::GetTexScrollMtx(speed));
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureShader0, 1);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PCT, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PCT);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
|
||||
GxXformPop(GxXform_Tex0);
|
||||
GxXformPop(GxXform_World);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Os/TimeManager.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00D4505C
|
||||
CDataAllocator Liquid::s_unk_D4505C(4, 8);
|
||||
|
||||
// STATIC: 0x00D45048
|
||||
CDataAllocator Liquid::s_unk_D45048(4, 8);
|
||||
|
||||
// STATIC: 0x00D44C34
|
||||
int32_t Liquid::CMaterialProcWater::s_refCount;
|
||||
|
||||
// STATIC: 0x00D44C24
|
||||
CGxShader* Liquid::CMaterialProcWater::s_vertexShaders[4];
|
||||
|
||||
// STATIC: 0x00D44C20
|
||||
CGxShader* Liquid::CMaterialProcWater::s_pixelShader;
|
||||
|
||||
// STATIC: 0x00D44C48
|
||||
Liquid::PSProcWaterConstants Liquid::s_psProcWaterConstants;
|
||||
|
||||
// STATIC: 0x00D44F88
|
||||
Liquid::VSWaveConstants Liquid::s_vsWaveConstants;
|
||||
|
||||
// VERIFY: 241af1fe manual
|
||||
// OFFSET: 0x008A3620
|
||||
void Liquid::SetDirectionalWave(uint32_t index, const C2Vector& direction, float a3, float a4, float a5, float speed) {
|
||||
Liquid::s_vsWaveConstants.m_directionalPhase[index] = static_cast<float>(static_cast<uint32_t>(OsGetAsyncTimeMs() * speed) & 0x1FFF) / 1024.0f * 6.2831855f;
|
||||
|
||||
float clampedA3 = a3 < 0.001f ? 0.001f : a3;
|
||||
C4Vector& wave = Liquid::s_vsWaveConstants.m_directionalWaves[index];
|
||||
wave.x = direction.x;
|
||||
wave.y = direction.y;
|
||||
wave.z = 1.0f / clampedA3;
|
||||
wave.w = a5;
|
||||
|
||||
Liquid::s_vsWaveConstants.unk_0050[index] = 1.0f / (a4 < 0.001f ? 0.001f : a4);
|
||||
}
|
||||
|
||||
// VERIFY: ffbfd269 manual
|
||||
// OFFSET: 0x008A3710
|
||||
void Liquid::SetCircularWave(uint32_t index, const C2Vector& a2, const C2Vector& a3, float a4, float a5, float a6, float speed) {
|
||||
Liquid::s_vsWaveConstants.m_circularPhase[index] = static_cast<float>(static_cast<uint32_t>(OsGetAsyncTimeMs() * speed) & 0x1FFF) / 1024.0f * 6.2831855f;
|
||||
|
||||
float invA4 = 1.0f / (a4 < 0.001f ? 0.001f : a4);
|
||||
Liquid::s_vsWaveConstants.unk_0060[index] = 1.0f / (a5 < 0.001f ? 0.001f : a5);
|
||||
|
||||
C4Vector& wave = Liquid::s_vsWaveConstants.m_circularWaves[index];
|
||||
wave.x = a2.x;
|
||||
wave.y = a2.y;
|
||||
wave.z = a3.x;
|
||||
wave.w = a3.y;
|
||||
|
||||
Liquid::s_vsWaveConstants.unk_00A0[index] = invA4;
|
||||
Liquid::s_vsWaveConstants.unk_00B0[index] = a6;
|
||||
}
|
||||
|
||||
// VERIFY: e47f29d4 manual
|
||||
// OFFSET: 0x008A3810
|
||||
void Liquid::SetProcWaterParams(float a1, float a2, float a3, float a4, float a5, float a6, float a7) {
|
||||
float* params = Liquid::s_psProcWaterConstants.m_params;
|
||||
params[0] = 1.0f / (a1 < 0.001f ? 0.001f : a1);
|
||||
params[1] = a2;
|
||||
params[2] = a3;
|
||||
params[3] = a4;
|
||||
params[4] = a7;
|
||||
params[5] = a5;
|
||||
params[6] = a6;
|
||||
params[7] = 0.0f;
|
||||
}
|
||||
|
||||
// VERIFY: e928fbf9 auto
|
||||
// OFFSET: 0x008A3C90
|
||||
void Liquid::SetProcWaterLighting(const CM2Lighting& lighting) {
|
||||
Liquid::s_psProcWaterConstants.m_sunDir.x = -lighting.m_sunDir.x;
|
||||
Liquid::s_psProcWaterConstants.m_sunDir.y = -lighting.m_sunDir.y;
|
||||
Liquid::s_psProcWaterConstants.m_sunDir.z = -lighting.m_sunDir.z;
|
||||
Liquid::s_psProcWaterConstants.m_sunDir.w = 0.0f;
|
||||
|
||||
Liquid::s_psProcWaterConstants.m_sunAmbient.x = lighting.m_sunAmbient.x;
|
||||
Liquid::s_psProcWaterConstants.m_sunAmbient.y = lighting.m_sunAmbient.y;
|
||||
Liquid::s_psProcWaterConstants.m_sunAmbient.z = lighting.m_sunAmbient.z;
|
||||
Liquid::s_psProcWaterConstants.m_sunAmbient.w = 0.0f;
|
||||
|
||||
Liquid::s_psProcWaterConstants.m_sunDiffuse.x = lighting.m_sunDiffuse.x;
|
||||
Liquid::s_psProcWaterConstants.m_sunDiffuse.y = lighting.m_sunDiffuse.y;
|
||||
Liquid::s_psProcWaterConstants.m_sunDiffuse.z = lighting.m_sunDiffuse.z;
|
||||
Liquid::s_psProcWaterConstants.m_sunDiffuse.w = 0.0f;
|
||||
|
||||
Liquid::s_psProcWaterConstants.m_sunSpecular.x = lighting.m_sunSpecular.x;
|
||||
Liquid::s_psProcWaterConstants.m_sunSpecular.y = lighting.m_sunSpecular.y;
|
||||
Liquid::s_psProcWaterConstants.m_sunSpecular.z = lighting.m_sunSpecular.z;
|
||||
Liquid::s_psProcWaterConstants.m_sunSpecular.w = 50.0f;
|
||||
}
|
||||
|
||||
// VERIFY: 616ba53c auto
|
||||
// OFFSET: 0x008A3DE0
|
||||
void Liquid::CMaterialProcWater::Release() {
|
||||
this->~CMaterialProcWater();
|
||||
Liquid::s_unk_D45048.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 624c4ea8 auto
|
||||
// OFFSET: 0x008A3E00
|
||||
Liquid::CMaterialProcWater::CMaterialProcWater() {
|
||||
if (Liquid::CMaterialProcWater::s_refCount++ == 0) {
|
||||
char name[256];
|
||||
SStrPrintf(name, sizeof(name), "vsLiquidProcWater%s", Liquid::GetShaderSuffix());
|
||||
g_theGxDevicePtr->ShaderCreate(Liquid::CMaterialProcWater::s_vertexShaders, GxSh_Vertex, "Shaders\\Vertex", name, 4);
|
||||
SStrPrintf(name, sizeof(name), "psLiquidProcWater%s", Liquid::GetShaderSuffix());
|
||||
g_theGxDevicePtr->ShaderCreate(&Liquid::CMaterialProcWater::s_pixelShader, GxSh_Pixel, "Shaders\\Pixel", name, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 0b2449de manual
|
||||
// OFFSET: 0x008A3EC0
|
||||
Liquid::CMaterialProcWater::~CMaterialProcWater() {
|
||||
if (Liquid::CMaterialProcWater::s_refCount-- == 1) {
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (Liquid::CMaterialProcWater::s_vertexShaders[i]) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialProcWater::s_vertexShaders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Liquid::CMaterialProcWater::s_pixelShader) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialProcWater::s_pixelShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 5b0d20f4 auto
|
||||
// OFFSET: 0x008A3F30
|
||||
void Liquid::CMaterialProcWaterFFP::Release() {
|
||||
this->~CMaterialProcWaterFFP();
|
||||
Liquid::s_unk_D4505C.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 46263496 auto
|
||||
// OFFSET: 0x008A4710
|
||||
Liquid::CMaterialProcWater* Liquid::CMaterialProcWater::Create() {
|
||||
void* mem = Liquid::s_unk_D45048.GetData(0, ".?AVCMaterialProcWater@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialProcWater() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 3ec533ba auto
|
||||
// OFFSET: 0x008A4770
|
||||
Liquid::CMaterialProcWaterFFP* Liquid::CMaterialProcWaterFFP::Create() {
|
||||
void* mem = Liquid::s_unk_D4505C.GetData(0, ".?AVCMaterialProcWaterFFP@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialProcWaterFFP() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: be2b8036 manual
|
||||
// OFFSET: 0x008A48F0
|
||||
void Liquid::CMaterialProcWater::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture0 = settings->GetTexture(0, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture1 = settings->GetTexture(1, 1250);
|
||||
|
||||
if (!texture1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* animTextures[2];
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
animTextures[i] = settings->GetTexture(i + 2, settings->GetInt(i + 1));
|
||||
|
||||
if (!animTextures[i]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CGxTex* texture4 = settings->GetTexture(4, 1250);
|
||||
|
||||
if (!texture4) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture5 = settings->GetTexture(5, settings->GetInt(3));
|
||||
|
||||
if (!texture5) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scales[4];
|
||||
float angles[4];
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
scales[i] = settings->GetFloat(i) * Liquid::WorldCoordScale();
|
||||
angles[i] = settings->GetFloat(i + 4) * 57.29578f;
|
||||
}
|
||||
|
||||
float scale4 = settings->GetFloat(8) * Liquid::WorldCoordScale();
|
||||
float scale5 = settings->GetFloat(9) * Liquid::WorldCoordScale();
|
||||
float angle5 = settings->GetFloat(10) * 57.29578f;
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
|
||||
bool identity = geomFactory->SetTransform(const_cast<C44Matrix*>(transform));
|
||||
geomFactory->GetBuffers(GxVBF_PT2, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PT2);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_DepthWrite, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Fog, 1);
|
||||
|
||||
Liquid::s_vsConstants.m_projection = g_theGxDevicePtr->m_projNative;
|
||||
|
||||
if (g_theGxDevicePtr->DeviceApi() == GxApi_OpenGl) {
|
||||
Liquid::s_vsConstants.m_projection.c0 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c1 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c2 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c3 *= -1.0f;
|
||||
}
|
||||
|
||||
C44Matrix matrix;
|
||||
Liquid::SetShaderTransforms(cameraPos, identity ? matrix : *transform);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
Liquid::SetShaderLighting(lighting);
|
||||
Liquid::SetProcWaterLighting(lighting);
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture1, texture1);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture2, texture4);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture3, texture5);
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
g_theGxDevicePtr->RsSet(static_cast<EGxRenderState>(GxRs_Texture4 + i), animTextures[i]);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
matrix = C44Matrix::RotationAroundZ(angles[i]);
|
||||
matrix.Scale(scales[i]);
|
||||
Liquid::s_vsConstants.m_texTransforms[i] = matrix;
|
||||
}
|
||||
|
||||
C44Matrix scaleMatrix;
|
||||
scaleMatrix.b1 = scale4;
|
||||
Liquid::s_vsConstants.m_texTransforms[4] = scaleMatrix;
|
||||
|
||||
C44Matrix rotationMatrix = C44Matrix::RotationAroundZ(angle5);
|
||||
rotationMatrix.Scale(scale5);
|
||||
Liquid::s_vsConstants.m_texTransforms[5] = rotationMatrix;
|
||||
|
||||
const float* waves = nullptr;
|
||||
const float* wavesEnd;
|
||||
|
||||
if (waveManager) {
|
||||
waves = static_cast<const float*>(waveManager->GetData());
|
||||
wavesEnd = waves + waveManager->GetCount();
|
||||
} else {
|
||||
wavesEnd = waves;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
if (waves + 6 > wavesEnd) {
|
||||
C2Vector direction;
|
||||
Liquid::SetDirectionalWave(i, direction, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
} else {
|
||||
C2Vector direction(waves[0], waves[1]);
|
||||
Liquid::SetDirectionalWave(i, direction, waves[2], waves[3], waves[4], waves[5]);
|
||||
}
|
||||
|
||||
waves += 6;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
if (waves + 8 > wavesEnd) {
|
||||
C2Vector a2;
|
||||
C2Vector a3;
|
||||
Liquid::SetCircularWave(i, a2, a3, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
} else {
|
||||
C2Vector a3(waves[2], waves[3]);
|
||||
C2Vector a2(waves[0], waves[1]);
|
||||
Liquid::SetCircularWave(i, a2, a3, waves[4], waves[5], waves[6], waves[7]);
|
||||
}
|
||||
|
||||
waves += 8;
|
||||
}
|
||||
|
||||
float param0 = settings->GetFloat(11) * Liquid::WorldCoordScale();
|
||||
float param1 = settings->GetFloat(12);
|
||||
float param2 = settings->GetFloat(13);
|
||||
float param3 = settings->GetFloat(14);
|
||||
float param4 = settings->GetFloat(15);
|
||||
float param5 = settings->GetFloat(16);
|
||||
float param6 = settings->GetFloat(17);
|
||||
Liquid::SetProcWaterParams(param0, param1, param2, param3, param4, param5, param6);
|
||||
|
||||
Liquid::SetShaderConstants();
|
||||
g_theGxDevicePtr->ShaderConstantsSet(GxSh_Vertex, 46, reinterpret_cast<const float*>(&Liquid::s_vsWaveConstants), 12);
|
||||
g_theGxDevicePtr->ShaderConstantsSet(GxSh_Pixel, 6, reinterpret_cast<const float*>(&Liquid::s_psProcWaterConstants), 6);
|
||||
|
||||
uint32_t lightCount = lighting.m_lightCount;
|
||||
|
||||
if (lightCount >= 3) {
|
||||
lightCount = 3;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_VertexShader, Liquid::CMaterialProcWater::s_vertexShaders[lightCount]);
|
||||
g_theGxDevicePtr->RsSet(GxRs_PixelShader, Liquid::CMaterialProcWater::s_pixelShader);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
|
||||
// VERIFY: 3685e63c manual
|
||||
// OFFSET: 0x008A5170
|
||||
void Liquid::CMaterialProcWaterFFP::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture0 = settings->GetTexture(4, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture1 = settings->GetTexture(5, settings->GetInt(2));
|
||||
|
||||
if (!texture1) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale0 = settings->GetFloat(8) * Liquid::WorldCoordScale();
|
||||
float scale1 = settings->GetFloat(9) * Liquid::WorldCoordScale();
|
||||
float angle1 = settings->GetFloat(10) * 57.29578f;
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->XformPush(GxXform_World);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
GxRsSet(GxRs_DepthWrite, g_theGxDevicePtr->Caps().m_maxClipPlanes == 0);
|
||||
|
||||
C44Matrix world = *transform;
|
||||
|
||||
if (Liquid::UseCameraRelativeCoords()) {
|
||||
world.d0 -= cameraPos.x;
|
||||
world.d1 -= cameraPos.y;
|
||||
world.d2 -= cameraPos.z;
|
||||
}
|
||||
|
||||
GxXformSet(GxXform_World, world);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
lighting.SetupGxLights(&cameraPos);
|
||||
lighting.SetupGxFog();
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureCoord0, 1);
|
||||
|
||||
C44Matrix texMatrix0;
|
||||
texMatrix0.b1 = scale0;
|
||||
g_theGxDevicePtr->XformPushAndSet(GxXform_Tex0, texMatrix0);
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture1, texture1);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureCoord1, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureShader1, 1);
|
||||
g_theGxDevicePtr->RsSet(GxRs_ColorOp1, 2);
|
||||
g_theGxDevicePtr->RsSet(GxRs_AlphaOp1, 3);
|
||||
|
||||
C44Matrix texMatrix1 = C44Matrix::RotationAroundZ(angle1);
|
||||
texMatrix1.Scale(scale1);
|
||||
g_theGxDevicePtr->XformPushAndSet(GxXform_Tex1, texMatrix1);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PNCT2, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PNCT2);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
|
||||
GxXformPop(GxXform_Tex1);
|
||||
GxXformPop(GxXform_Tex0);
|
||||
GxXformPop(GxXform_World);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00D45098
|
||||
CDataAllocator Liquid::s_unk_D45098(4, 8);
|
||||
|
||||
// STATIC: 0x00D45084
|
||||
CDataAllocator Liquid::s_unk_D45084(4, 8);
|
||||
|
||||
// STATIC: 0x00D45070
|
||||
CDataAllocator Liquid::s_unk_D45070(4, 8);
|
||||
|
||||
// STATIC: 0x00D44C38
|
||||
int32_t Liquid::CMaterialWater::s_refCount;
|
||||
|
||||
// STATIC: 0x00D44C10
|
||||
CGxShader* Liquid::CMaterialWater::s_vertexShaders[4];
|
||||
|
||||
// STATIC: 0x00D44C0C
|
||||
CGxShader* Liquid::CMaterialWater::s_pixelShader;
|
||||
|
||||
// STATIC: 0x00D44C3C
|
||||
int32_t Liquid::CMaterialWaterNoSpec::s_refCount;
|
||||
|
||||
// STATIC: 0x00D44BFC
|
||||
CGxShader* Liquid::CMaterialWaterNoSpec::s_vertexShaders[4];
|
||||
|
||||
// STATIC: 0x00D44BF8
|
||||
CGxShader* Liquid::CMaterialWaterNoSpec::s_pixelShader;
|
||||
|
||||
// VERIFY: 6cccb7b7 auto
|
||||
// OFFSET: 0x008A3F50
|
||||
void Liquid::CMaterialWater::Release() {
|
||||
this->~CMaterialWater();
|
||||
Liquid::s_unk_D45070.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 05103905 auto
|
||||
// OFFSET: 0x008A3F70
|
||||
Liquid::CMaterialWater::CMaterialWater() {
|
||||
if (Liquid::CMaterialWater::s_refCount++ == 0) {
|
||||
g_theGxDevicePtr->ShaderCreate(Liquid::CMaterialWater::s_vertexShaders, GxSh_Vertex, "Shaders\\Vertex", "vsLiquidWater", 4);
|
||||
g_theGxDevicePtr->ShaderCreate(&Liquid::CMaterialWater::s_pixelShader, GxSh_Pixel, "Shaders\\Pixel", "psLiquidWater", 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 181045ab manual
|
||||
// OFFSET: 0x008A3FE0
|
||||
Liquid::CMaterialWater::~CMaterialWater() {
|
||||
if (Liquid::CMaterialWater::s_refCount-- == 1) {
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (Liquid::CMaterialWater::s_vertexShaders[i]) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialWater::s_vertexShaders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Liquid::CMaterialWater::s_pixelShader) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialWater::s_pixelShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 62a636a6 auto
|
||||
// OFFSET: 0x008A4050
|
||||
void Liquid::CMaterialWaterNoSpec::Release() {
|
||||
this->~CMaterialWaterNoSpec();
|
||||
Liquid::s_unk_D45084.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 4a9ff4b4 auto
|
||||
// OFFSET: 0x008A4070
|
||||
Liquid::CMaterialWaterNoSpec::CMaterialWaterNoSpec() {
|
||||
if (Liquid::CMaterialWaterNoSpec::s_refCount++ == 0) {
|
||||
g_theGxDevicePtr->ShaderCreate(Liquid::CMaterialWaterNoSpec::s_vertexShaders, GxSh_Vertex, "Shaders\\Vertex", "vsLiquidWaterNoSpec", 4);
|
||||
g_theGxDevicePtr->ShaderCreate(&Liquid::CMaterialWaterNoSpec::s_pixelShader, GxSh_Pixel, "Shaders\\Pixel", "psLiquidWaterNoSpec", 1);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: eafe186b manual
|
||||
// OFFSET: 0x008A40E0
|
||||
Liquid::CMaterialWaterNoSpec::~CMaterialWaterNoSpec() {
|
||||
if (Liquid::CMaterialWaterNoSpec::s_refCount-- == 1) {
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (Liquid::CMaterialWaterNoSpec::s_vertexShaders[i]) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialWaterNoSpec::s_vertexShaders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Liquid::CMaterialWaterNoSpec::s_pixelShader) {
|
||||
g_theGxDevicePtr->ShaderDestroy(Liquid::CMaterialWaterNoSpec::s_pixelShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2a90d358 auto
|
||||
// OFFSET: 0x008A4150
|
||||
void Liquid::CMaterialWaterFFP::Release() {
|
||||
this->~CMaterialWaterFFP();
|
||||
Liquid::s_unk_D45098.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: b9a59821 auto
|
||||
// OFFSET: 0x008A4790
|
||||
Liquid::CMaterialWater* Liquid::CMaterialWater::Create() {
|
||||
void* mem = Liquid::s_unk_D45070.GetData(0, ".?AVCMaterialWater@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialWater() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 942c0c77 auto
|
||||
// OFFSET: 0x008A47F0
|
||||
Liquid::CMaterialWaterNoSpec* Liquid::CMaterialWaterNoSpec::Create() {
|
||||
void* mem = Liquid::s_unk_D45084.GetData(0, ".?AVCMaterialWaterNoSpec@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialWaterNoSpec() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 193cac49 auto
|
||||
// OFFSET: 0x008A4850
|
||||
Liquid::CMaterialWaterFFP* Liquid::CMaterialWaterFFP::Create() {
|
||||
void* mem = Liquid::s_unk_D45098.GetData(0, ".?AVCMaterialWaterFFP@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CMaterialWaterFFP() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: a882be97 manual
|
||||
// OFFSET: 0x008A5590
|
||||
void Liquid::CMaterialWater::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture1 = settings->GetTexture(0, settings->GetInt(1));
|
||||
|
||||
if (!texture1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture0 = settings->GetTexture(1, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale1 = settings->GetFloat(0);
|
||||
float angle1 = settings->GetFloat(1) * 57.29578f;
|
||||
float scale0 = settings->GetFloat(2);
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
GxRsSet(GxRs_DepthWrite, g_theGxDevicePtr->Caps().m_maxClipPlanes == 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Fog, 1);
|
||||
|
||||
Liquid::s_vsConstants.m_projection = g_theGxDevicePtr->m_projNative;
|
||||
|
||||
if (g_theGxDevicePtr->DeviceApi() == GxApi_OpenGl) {
|
||||
Liquid::s_vsConstants.m_projection.c0 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c1 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c2 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c3 *= -1.0f;
|
||||
}
|
||||
|
||||
C44Matrix matrix;
|
||||
Liquid::SetShaderTransforms(cameraPos, geomFactory->SetTransform(const_cast<C44Matrix*>(transform)) ? matrix : *transform);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
Liquid::SetShaderLighting(lighting);
|
||||
|
||||
C44Matrix texMatrix1;
|
||||
texMatrix1.b1 = scale0;
|
||||
Liquid::s_vsConstants.m_texTransforms[1] = texMatrix1;
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
|
||||
C44Matrix texMatrix0 = C44Matrix::RotationAroundZ(angle1);
|
||||
texMatrix0.Scale(scale1);
|
||||
Liquid::s_vsConstants.m_texTransforms[0] = texMatrix0;
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture1, texture1);
|
||||
Liquid::SetShaderConstants();
|
||||
|
||||
uint32_t lightCount = lighting.m_lightCount;
|
||||
|
||||
if (lightCount >= 3) {
|
||||
lightCount = 3;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_VertexShader, Liquid::CMaterialWater::s_vertexShaders[lightCount]);
|
||||
g_theGxDevicePtr->RsSet(GxRs_PixelShader, Liquid::CMaterialWater::s_pixelShader);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PNCT2, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PNCT2);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
|
||||
// VERIFY: b899ce66 manual
|
||||
// OFFSET: 0x008A5900
|
||||
void Liquid::CMaterialWaterNoSpec::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture1 = settings->GetTexture(0, settings->GetInt(1));
|
||||
|
||||
if (!texture1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture0 = settings->GetTexture(1, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale1 = settings->GetFloat(0);
|
||||
float angle1 = settings->GetFloat(1) * 57.29578f;
|
||||
float scale0 = settings->GetFloat(2);
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
GxRsSet(GxRs_DepthWrite, g_theGxDevicePtr->Caps().m_maxClipPlanes == 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Fog, 1);
|
||||
|
||||
Liquid::s_vsConstants.m_projection = g_theGxDevicePtr->m_projNative;
|
||||
|
||||
if (g_theGxDevicePtr->DeviceApi() == GxApi_OpenGl) {
|
||||
Liquid::s_vsConstants.m_projection.c0 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c1 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c2 *= -1.0f;
|
||||
Liquid::s_vsConstants.m_projection.c3 *= -1.0f;
|
||||
}
|
||||
|
||||
C44Matrix matrix;
|
||||
Liquid::SetShaderTransforms(cameraPos, geomFactory->SetTransform(const_cast<C44Matrix*>(transform)) ? matrix : *transform);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
Liquid::SetShaderLighting(lighting);
|
||||
|
||||
C44Matrix texMatrix1;
|
||||
texMatrix1.b1 = scale0;
|
||||
Liquid::s_vsConstants.m_texTransforms[1] = texMatrix1;
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
|
||||
C44Matrix texMatrix0 = C44Matrix::RotationAroundZ(angle1);
|
||||
texMatrix0.Scale(scale1);
|
||||
Liquid::s_vsConstants.m_texTransforms[0] = texMatrix0;
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture1, texture1);
|
||||
Liquid::SetShaderConstants();
|
||||
|
||||
uint32_t lightCount = lighting.m_lightCount;
|
||||
|
||||
if (lightCount >= 3) {
|
||||
lightCount = 3;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_VertexShader, Liquid::CMaterialWaterNoSpec::s_vertexShaders[lightCount]);
|
||||
g_theGxDevicePtr->RsSet(GxRs_PixelShader, Liquid::CMaterialWaterNoSpec::s_pixelShader);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PNCT2, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PNCT2);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
|
||||
// VERIFY: 556f1caa manual
|
||||
// OFFSET: 0x008A5C70
|
||||
void Liquid::CMaterialWaterFFP::Render(Liquid::IEnvironment* environment, Liquid::IGeomFactory* geomFactory, Liquid::IWaveManager* waveManager, const C3Vector& cameraPos, const C44Matrix* transform, const CAaSphere* bounds, Liquid::CMaterialSettings* settings) {
|
||||
CGxTex* texture1 = settings->GetTexture(0, settings->GetInt(1));
|
||||
|
||||
if (!texture1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGxTex* texture0 = settings->GetTexture(1, 1250);
|
||||
|
||||
if (!texture0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale1 = settings->GetFloat(0) * Liquid::WorldCoordScale();
|
||||
float angle1 = settings->GetFloat(1) * 57.29578f;
|
||||
float scale0 = settings->GetFloat(2) * Liquid::WorldCoordScale();
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
g_theGxDevicePtr->XformPush(GxXform_World);
|
||||
g_theGxDevicePtr->RsSet(GxRs_Culling, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
GxRsSet(GxRs_DepthWrite, g_theGxDevicePtr->Caps().m_maxClipPlanes == 0);
|
||||
|
||||
C44Matrix world = *transform;
|
||||
|
||||
if (Liquid::UseCameraRelativeCoords()) {
|
||||
world.d0 -= cameraPos.x;
|
||||
world.d1 -= cameraPos.y;
|
||||
world.d2 -= cameraPos.z;
|
||||
}
|
||||
|
||||
GxXformSet(GxXform_World, world);
|
||||
|
||||
CM2Lighting lighting(*bounds);
|
||||
environment->SelectLights(&lighting);
|
||||
lighting.SetupGxLights(&cameraPos);
|
||||
lighting.SetupGxFog();
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture0, texture0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureCoord0, 1);
|
||||
|
||||
C44Matrix texMatrix0;
|
||||
texMatrix0.b1 = scale0;
|
||||
g_theGxDevicePtr->XformPushAndSet(GxXform_Tex0, texMatrix0);
|
||||
|
||||
g_theGxDevicePtr->RsSet(GxRs_Texture1, texture1);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureCoord1, 0);
|
||||
g_theGxDevicePtr->RsSet(GxRs_TextureShader1, 1);
|
||||
g_theGxDevicePtr->RsSet(GxRs_ColorOp1, 2);
|
||||
g_theGxDevicePtr->RsSet(GxRs_AlphaOp1, 3);
|
||||
|
||||
C44Matrix texMatrix1 = C44Matrix::RotationAroundZ(angle1);
|
||||
texMatrix1.Scale(scale1);
|
||||
g_theGxDevicePtr->XformPushAndSet(GxXform_Tex1, texMatrix1);
|
||||
|
||||
CGxBuf* vertexBuf = nullptr;
|
||||
CGxBuf* indexBuf = nullptr;
|
||||
CGxBatch batch;
|
||||
batch.m_primType = GxPrims_Last;
|
||||
batch.m_start = 0;
|
||||
batch.m_count = 0;
|
||||
batch.m_minIndex = 0;
|
||||
batch.m_maxIndex = 0;
|
||||
geomFactory->GetBuffers(GxVBF_PNCT2, &vertexBuf, &indexBuf, &batch);
|
||||
GxPrimVertexPtr(vertexBuf, GxVBF_PNCT2);
|
||||
g_theGxDevicePtr->PrimIndexPtr(indexBuf);
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
|
||||
GxXformPop(GxXform_Tex1);
|
||||
GxXformPop(GxXform_Tex0);
|
||||
GxXformPop(GxXform_World);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef WOW_SOURCE_LIQUIDSYSTEM_TYPES_H
|
||||
#define WOW_SOURCE_LIQUIDSYSTEM_TYPES_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
struct SMLiquidChunkDesc {
|
||||
/* 0000 */ uint32_t m_offsetInstances;
|
||||
/* 0004 */ uint32_t m_layerCount;
|
||||
/* 0008 */ uint32_t m_offsetAttributes;
|
||||
};
|
||||
|
||||
struct SMLiquidInstance {
|
||||
/* 0000 */ uint16_t m_liquidType;
|
||||
/* 0002 */ uint16_t m_vertexFormat;
|
||||
/* 0004 */ float m_minHeight;
|
||||
/* 0008 */ float m_maxHeight;
|
||||
/* 000C */ uint8_t m_xOffset;
|
||||
/* 000D */ uint8_t m_yOffset;
|
||||
/* 000E */ uint8_t m_width;
|
||||
/* 000F */ uint8_t m_height;
|
||||
/* 0010 */ uint32_t m_offsetExistsBitmap;
|
||||
/* 0014 */ uint32_t m_offsetVertexData;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -849,3 +849,32 @@ void LoadingScreenMiniUpdate(float progress) {
|
||||
LoadingScreenMiniEnable();
|
||||
s_progress = progress;
|
||||
}
|
||||
|
||||
// VERIFY: c6318812 manual
|
||||
// OFFSET: 0x0040A160
|
||||
bool LoadDynamicBackground() {
|
||||
CStatus status;
|
||||
|
||||
if (!s_dynamicElementsTexture) {
|
||||
CGxTexFlags flags;
|
||||
s_dynamicElementsTexture = TextureCreate("Interface\\Glues\\LoadingScreens\\DynamicElements", flags, &status, 1);
|
||||
|
||||
if (!s_dynamicElementsTexture) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 12; i++) {
|
||||
char fileName[260];
|
||||
SStrPrintf(fileName, sizeof(fileName), "Interface\\WorldMap\\World\\World%d", i + 1);
|
||||
|
||||
CGxTexFlags flags;
|
||||
s_dynamicBackgroundTextures[i] = TextureCreate(fileName, flags, &status, 1);
|
||||
|
||||
if (!s_dynamicBackgroundTextures[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "CChunkLiquid.h"
|
||||
@@ -3,61 +3,62 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Tempest/C2Vector.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Base/BitArray.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Tempest/C2Vector.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
|
||||
class CChunkLiquid;
|
||||
class CMapChunk;
|
||||
class CMapChunkLiquidBuf;
|
||||
|
||||
class CChunkGeomFactory {
|
||||
public:
|
||||
/* 0004 */ uint32_t unk_0004;
|
||||
/* 0008 */ uint32_t unk_0008;
|
||||
/* 000C */ uint32_t unk_000C;
|
||||
/* 0010 */ uint32_t unk_0010;
|
||||
/* 0014 */ CChunkLiquid* m_liquidChunk;
|
||||
/* 0018 */ uint32_t unk_0018;
|
||||
/* 001C */ CMapChunkLiquidBuf* m_mapChunkBuf;
|
||||
/* 0020 */ uint32_t unk_0020;
|
||||
/* 0024 */ uint32_t unk_0024;
|
||||
/* 0028 */ uint32_t unk_0028;
|
||||
/* 002C */ uint16_t m_unkFlags2c;
|
||||
/* 002E */ uint16_t m_unkFlags2e;
|
||||
/* 0030 */ uint32_t unk_0030;
|
||||
/* 0034 */ C44Matrix m_matrix;
|
||||
|
||||
virtual ~CChunkGeomFactory();
|
||||
};
|
||||
namespace Liquid {
|
||||
class CInstance;
|
||||
class CWaveManager;
|
||||
class IVertexData;
|
||||
}
|
||||
|
||||
class CChunkLiquid {
|
||||
public:
|
||||
static Liquid::CWaveManager* s_waveManager;
|
||||
static int32_t s_waveManagerRefs;
|
||||
|
||||
/* 0000 */ int32_t m_objectIndex;
|
||||
/* 0004 */ int32_t unk_0004;
|
||||
/* 0004 */ int32_t m_type;
|
||||
/* 0008 */ int32_t unk_0008;
|
||||
/* 000C */ C3Vector m_topLeftCoords;
|
||||
/* 0018 */ C3Vector m_center;
|
||||
/* 0024 */ float m_radius;
|
||||
/* 0018 */ CAaSphere m_sphere;
|
||||
/* 0028 */ C2Vector m_height;
|
||||
/* 0030 */ float m_resPurgeTimer;
|
||||
/* 0034 */ C2iVector m_tileBegin;
|
||||
/* 003C */ C2iVector m_tileEnd;
|
||||
/* 0044 */ int32_t unk_0044;
|
||||
/* 0048 */ int32_t unk_0048;
|
||||
/* 004C */ int32_t unk_004C;
|
||||
/* 0050 */ int32_t unk_0050;
|
||||
/* 0044 */ Liquid::IVertexData* m_vertexData;
|
||||
/* 0048 */ CBitArray m_tileBits;
|
||||
/* 0054 */ uint8_t* m_tiles;
|
||||
/* 0058 */ uint8_t* m_liquidInstPtr;
|
||||
/* 0058 */ Liquid::CInstance* m_instance;
|
||||
/* 005C */ CMapChunk* m_owner;
|
||||
/* 0060 */ CChunkLiquid* m_prev;
|
||||
/* 0064 */ CChunkLiquid* m_next;
|
||||
/* 0068 */ int32_t unk_0068;
|
||||
/* 006C */ int32_t unk_006C;
|
||||
/* 0070 */ int32_t unk_0070;
|
||||
/* 0074 */ int32_t unk_0074;
|
||||
/* 0078 */ C3Vector m_verts [81];
|
||||
/* 0060 */ TSLink<CChunkLiquid> m_link;
|
||||
/* 0068 */ TSLink<CChunkLiquid> m_updateLink;
|
||||
/* 0070 */ TSLink<CChunkLiquid> m_chunkLink;
|
||||
/* 0078 */ C3Vector m_verts[81];
|
||||
|
||||
CChunkLiquid();
|
||||
~CChunkLiquid();
|
||||
void Batch();
|
||||
void BuildIndices(uint16_t* indices, uint16_t baseVertex, CGxBatch* batch) const;
|
||||
void BuildVertices(const C44Matrix* transform, uint32_t stride, C3Vector** position, C3Vector** normal, uint32_t** color, C2Vector** texCoord1, C2Vector** texCoord0) const;
|
||||
void CreateVertXY();
|
||||
void GetAaBox(CAaBox& box) const;
|
||||
bool GetHeight(const C2Vector& frac, const C2iVector& tile, float& height) const;
|
||||
CAaSphere* GetSphere();
|
||||
bool GetTileInfo(const C2iVector& tile, int32_t* type, int32_t* flag6, int32_t* flag7) const;
|
||||
void Purge();
|
||||
void RenderPrep();
|
||||
bool TileExists(uint32_t x, uint32_t y) const;
|
||||
void UpdateResourcePurging();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,135 @@
|
||||
#include "CWorldMath.h"
|
||||
#include "Engine/Source/Tempest/C33Matrix.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include <cmath>
|
||||
|
||||
// VERIFY: a0e6ed09 manual
|
||||
// OFFSET: 0x007A61D0
|
||||
int32_t CWorldMath::ComputeAaBoxOutcode(CAaBox* box, C3Vector* point) {
|
||||
float d0 = point->x - box->b.x + 0.019444443f;
|
||||
float d1 = point->y - box->b.y + 0.019444443f;
|
||||
float d2 = point->z - box->b.z + 0.019444443f;
|
||||
float d3 = box->t.x - point->x + 0.019444443f;
|
||||
float d4 = box->t.y - point->y + 0.019444443f;
|
||||
float d5 = box->t.z - point->z + 0.019444443f;
|
||||
|
||||
uint32_t outcode = *reinterpret_cast<uint32_t*>(&d0) >> 31;
|
||||
outcode |= (*reinterpret_cast<uint32_t*>(&d1) >> 30) & 0x02;
|
||||
outcode |= (*reinterpret_cast<uint32_t*>(&d2) >> 29) & 0x04;
|
||||
outcode |= (*reinterpret_cast<uint32_t*>(&d3) >> 28) & 0x08;
|
||||
outcode |= (*reinterpret_cast<uint32_t*>(&d4) >> 27) & 0x10;
|
||||
outcode |= (*reinterpret_cast<uint32_t*>(&d5) >> 26) & 0x20;
|
||||
|
||||
return outcode;
|
||||
}
|
||||
|
||||
// VERIFY: fc48135f auto
|
||||
// OFFSET: 0x007F9320
|
||||
void CWorldMath::TransformAABoxInner(const float* row1, const float* row0, CAaBox& dst, CAaBox& src, const float* row2) {
|
||||
const float* rows[3] = { row0, row1, row2 };
|
||||
|
||||
for (int32_t axis = 0; axis < 3; axis++) {
|
||||
for (int32_t component = 0; component < 3; component++) {
|
||||
float e = rows[component][axis];
|
||||
|
||||
float a = e * (&src.b.x)[component];
|
||||
float b = e * (&src.t.x)[component];
|
||||
|
||||
(&dst.b.x)[axis] += a < b ? a : b;
|
||||
(&dst.t.x)[axis] += a < b ? b : a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 51bf69b0 manual
|
||||
// OFFSET: 0x007F93D0
|
||||
void CWorldMath::TransformAABox(C33Matrix& m, CAaBox& src, CAaBox& dst) {
|
||||
dst.b = { 0.0f, 0.0f, 0.0f };
|
||||
dst.t = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
CWorldMath::TransformAABoxInner(&m.b0, &m.a0, dst, src, &m.c0);
|
||||
}
|
||||
|
||||
// VERIFY: 07b42bca manual
|
||||
// OFFSET: 0x007F9430
|
||||
void CWorldMath::TransformAABox(C44Matrix& m, CAaBox& src, CAaBox& dst) {
|
||||
dst.b = C3Vector(m.d0, m.d1, m.d2);
|
||||
dst.t = C3Vector(m.d0, m.d1, m.d2);
|
||||
|
||||
CWorldMath::TransformAABoxInner(&m.b0, &m.a0, dst, src, &m.c0);
|
||||
}
|
||||
|
||||
// VERIFY: 011d2b0a manual
|
||||
// OFFSET: 0x007F9480
|
||||
bool CWorldMath::VectorIntersectAABox2(CAaBox& box, C3Vector& start, C3Vector& end) {
|
||||
const float* minB = &box.b.x;
|
||||
const float* maxB = &box.t.x;
|
||||
const float* origin = &start.x;
|
||||
const float* target = &end.x;
|
||||
|
||||
float hit[3];
|
||||
float dir[3];
|
||||
float maxT[3];
|
||||
|
||||
dir[0] = end.x - start.x;
|
||||
dir[1] = end.y - start.y;
|
||||
dir[2] = end.z - start.z;
|
||||
maxT[0] = -1.0f;
|
||||
maxT[1] = -1.0f;
|
||||
maxT[2] = -1.0f;
|
||||
|
||||
int32_t inside = 1;
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
if (origin[i] < minB[i]) {
|
||||
if (target[i] < minB[i]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hit[i] = minB[i];
|
||||
inside = 0;
|
||||
|
||||
if (dir[i] != 0.0f) {
|
||||
maxT[i] = (minB[i] - origin[i]) / dir[i];
|
||||
}
|
||||
} else if (origin[i] > maxB[i]) {
|
||||
if (target[i] > maxB[i]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hit[i] = maxB[i];
|
||||
inside = 0;
|
||||
|
||||
if (dir[i] != 0.0f) {
|
||||
maxT[i] = (maxB[i] - origin[i]) / dir[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inside) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t plane = maxT[0] < maxT[1];
|
||||
|
||||
if (maxT[plane] < maxT[2]) {
|
||||
plane = 2;
|
||||
}
|
||||
|
||||
if (*reinterpret_cast<uint32_t*>(&maxT[plane]) & 0x80000000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
if (i != plane) {
|
||||
hit[i] = origin[i] + maxT[plane] * dir[i];
|
||||
|
||||
if (minB[i] - 0.00001f > hit[i] || maxB[i] + 0.00001f < hit[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_CWORLDMATH_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_CWORLDMATH_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class C33Matrix;
|
||||
class C3Vector;
|
||||
class C44Matrix;
|
||||
class CAaBox;
|
||||
|
||||
class CWorldMath {
|
||||
public:
|
||||
static void TransformAABox(C44Matrix& m, CAaBox& src, CAaBox& dst);
|
||||
static void TransformAABoxInner(const float* row1, const float* row0, CAaBox& dst, CAaBox& src, const float* row2);
|
||||
static void TransformAABox(C33Matrix& m, CAaBox& src, CAaBox& dst);
|
||||
static bool VectorIntersectAABox2(CAaBox& box, C3Vector& start, C3Vector& end);
|
||||
static int32_t ComputeAaBoxOutcode(CAaBox* box, C3Vector* point);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
|
||||
class C3Vector;
|
||||
class CAaBox;
|
||||
class CAaSphere;
|
||||
|
||||
class CWorldOccluder {
|
||||
public:
|
||||
static void Initialize();
|
||||
@@ -28,4 +32,14 @@ class CClipVolume {
|
||||
/* 0004 */ uint32_t m_planeCount;
|
||||
};
|
||||
|
||||
class CWorldOcclusion {
|
||||
public:
|
||||
static void ClearVolumes();
|
||||
static uint32_t GetClipVolumeCount();
|
||||
static uint32_t QueryVolumes(CAaSphere* sphere);
|
||||
static uint32_t QueryVolumes(C3Vector* sphere, uint32_t count);
|
||||
static uint32_t QueryBuffer(CAaBox* box, uint8_t flags);
|
||||
static uint32_t QueryBuffer(CAaSphere* box, uint8_t flags);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,42 @@
|
||||
#include "CWorldSceneRender.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
|
||||
// VERIFY: 78b69e1a manual
|
||||
// OFFSET: 0x007D5610
|
||||
void CWorldScene::RenderCollisionDebug() {
|
||||
if (!CMap::debugVertexArray.Count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->RsPush();
|
||||
GxRsSet(GxRs_PolygonOffset, 1.0f);
|
||||
|
||||
C44Matrix matrix;
|
||||
matrix.Translate(C3Vector(-CWorldScene::s_activeWorldView.x, -CWorldScene::s_activeWorldView.y, -CWorldScene::s_activeWorldView.z));
|
||||
g_theGxDevicePtr->XformPushAndSet(GxXform_World, matrix);
|
||||
|
||||
GxRsSet(GxRs_BlendingMode, 2);
|
||||
GxUpdateAlphaRef(GxRs_AlphaRef);
|
||||
GxRsSet(GxRs_Lighting, 0);
|
||||
GxRsSet(GxRs_DepthWrite, 0);
|
||||
GxRsSet(GxRs_DepthTest, 0);
|
||||
GxRsSet(GxRs_Culling, 0);
|
||||
|
||||
CGxVertexPC* vertices = CMap::debugVertexArray.m_data;
|
||||
GxPrimVertexPtr(CMap::debugVertexArray.Count(), &vertices->p, sizeof(CGxVertexPC), nullptr, 0, &vertices->c, sizeof(CGxVertexPC), nullptr, 0, nullptr, 0);
|
||||
GxPrimIndexPtr(CMap::debugIndexArray.Count(), CMap::debugIndexArray.m_data);
|
||||
|
||||
CGxBatch batch;
|
||||
batch.m_count = CMap::debugIndexArray.Count();
|
||||
batch.m_maxIndex = CMap::debugVertexArray.Count() - 1;
|
||||
batch.m_primType = GxPrim_Triangles;
|
||||
batch.m_start = 0;
|
||||
batch.m_minIndex = 0;
|
||||
g_theGxDevicePtr->Draw(&batch, 1);
|
||||
|
||||
GxXformPop(GxXform_World);
|
||||
g_theGxDevicePtr->RsPop();
|
||||
}
|
||||
|
||||
@@ -1 +1,17 @@
|
||||
#include "ClipInfo.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
|
||||
// VERIFY: caefdc42 auto
|
||||
// OFFSET: 0x0078FFA0
|
||||
void World::CLIPINFO::Set(const C3Vector& ndc) {
|
||||
this->d[0] = ndc.x;
|
||||
this->d[1] = 1.0f - ndc.x;
|
||||
this->d[2] = ndc.y;
|
||||
this->d[3] = 1.0f - ndc.y;
|
||||
this->d[4] = ndc.z;
|
||||
this->d[5] = 1.0f - ndc.z;
|
||||
|
||||
const uint32_t* bits = reinterpret_cast<const uint32_t*>(this->d);
|
||||
|
||||
this->outcode = (bits[0] & 0x80000000) + ((bits[1] >> 1) & 0x40000000) + ((bits[2] >> 2) & 0x20000000) + ((bits[3] >> 3) & 0x10000000) + ((bits[4] >> 4) & 0x08000000) + ((bits[5] >> 5) & 0x04000000);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class C3Vector;
|
||||
|
||||
class ClipInfo {
|
||||
public:
|
||||
/* 0000 */ uint32_t unk_0000;
|
||||
@@ -15,4 +17,17 @@ class ClipInfo {
|
||||
/* 0018 */ uint32_t unk_0018;
|
||||
};
|
||||
|
||||
namespace World {
|
||||
|
||||
struct CLIPINFO {
|
||||
float d[6];
|
||||
uint32_t outcode;
|
||||
uint32_t pad;
|
||||
|
||||
void Set(const C3Vector& ndc);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,19 @@
|
||||
#include "Engine/Source/Gx/CGxBuf.h"
|
||||
#include "Engine/Source/Gx/CGxPool.h"
|
||||
|
||||
// VERIFY: 931e6f81 manual
|
||||
// OFFSET: 0x007D55B0
|
||||
void FVBBList::Release(Block* block) {
|
||||
if (!block) {
|
||||
return;
|
||||
}
|
||||
|
||||
*block->m_owner = nullptr;
|
||||
block->m_owner = nullptr;
|
||||
block->m_link.Unlink();
|
||||
this->m_blocks.LinkToTail(block);
|
||||
}
|
||||
|
||||
// VERIFY: 59fe6fba manual
|
||||
// OFFSET: 0x007D58B0
|
||||
void FVBBList::Initialize(EGxPoolTarget target, EGxPoolUsage usage, uint32_t itemSize, uint32_t itemCount, uint32_t blockCount) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class FVBBList {
|
||||
/* 0000 */ TSLink<Block> m_link;
|
||||
/* 0008 */ uint32_t unk_0008;
|
||||
/* 000C */ CGxBuf* m_buf;
|
||||
/* 0010 */ uint32_t unk_0010;
|
||||
/* 0010 */ Block** m_owner;
|
||||
};
|
||||
|
||||
/* 0000 */ CGxPool* m_pool;
|
||||
@@ -24,6 +24,7 @@ class FVBBList {
|
||||
|
||||
void Destroy();
|
||||
void Initialize(EGxPoolTarget target, EGxPoolUsage usage, uint32_t itemSize, uint32_t itemCount, uint32_t blockCount);
|
||||
void Release(Block* block);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
#include "Liquid.h"
|
||||
#include "Engine/Source/Base/Handle.h"
|
||||
#include "Engine/Source/Gx/CGxTexFlags.h"
|
||||
#include "Engine/Source/Services/Texture.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
|
||||
// STATIC: 0x00D31960
|
||||
CDataAllocator Liquid::s_unk_D31960(0x48, 4);
|
||||
|
||||
// STATIC: 0x00D31974
|
||||
CDataAllocator Liquid::s_unk_D31974(0x74, 0x10);
|
||||
|
||||
// STATIC: 0x00D31A00
|
||||
CDataAllocator Liquid::s_unk_D31A00(0xC, 0x10);
|
||||
|
||||
// STATIC: 0x00D31A30
|
||||
CDataAllocator Liquid::s_unk_D31A30(0x128, 0x10);
|
||||
|
||||
// STATIC: 0x00D43B00
|
||||
CDataAllocator Liquid::s_unk_D43B00(0x43C, 0x20);
|
||||
|
||||
// STATIC: 0x00D43B24
|
||||
TSGrowableArray<Liquid::IMaterial*> Liquid::CMaterialBank::s_unk_D43B24;
|
||||
|
||||
// STATIC: 0x00D43B34
|
||||
CDataAllocator Liquid::s_unk_D43B34(0x6C, 0x20);
|
||||
|
||||
// STATIC: 0x00D45048
|
||||
CDataAllocator Liquid::s_unk_D45048(4, 8);
|
||||
|
||||
// STATIC: 0x00D4505C
|
||||
CDataAllocator Liquid::s_unk_D4505C(4, 8);
|
||||
|
||||
// STATIC: 0x00D45070
|
||||
CDataAllocator Liquid::s_unk_D45070(4, 8);
|
||||
|
||||
// STATIC: 0x00D45084
|
||||
CDataAllocator Liquid::s_unk_D45084(4, 8);
|
||||
|
||||
// STATIC: 0x00D45098
|
||||
CDataAllocator Liquid::s_unk_D45098(4, 8);
|
||||
|
||||
// STATIC: 0x00D450AC
|
||||
CDataAllocator Liquid::s_unk_D450AC(4, 8);
|
||||
|
||||
// STATIC: 0x00D450C0
|
||||
CDataAllocator Liquid::s_unk_D450C0(4, 8);
|
||||
|
||||
// STATIC: 0x00B23F64
|
||||
float Liquid::s_unk_B23F64 = 1.0f;
|
||||
|
||||
// STATIC: 0x00B23F68
|
||||
int32_t Liquid::s_unk_B23F68 = 1;
|
||||
|
||||
// STATIC: 0x00D439E8
|
||||
IDatabase<LiquidMaterialRec>* Liquid::s_liquidMaterialDB;
|
||||
|
||||
// STATIC: 0x00D439EC
|
||||
IDatabase<LiquidTypeRec>* Liquid::s_liquidTypeDB;
|
||||
|
||||
// STATIC: 0x00D439F0
|
||||
char Liquid::s_unk_D439F0[256];
|
||||
|
||||
// STATIC: 0x00D43AF0
|
||||
int32_t Liquid::s_unk_D43AF0;
|
||||
|
||||
// STATIC: 0x00D43AF4
|
||||
int32_t Liquid::s_unk_D43AF4;
|
||||
|
||||
// STATIC: 0x00D43AF8
|
||||
int32_t Liquid::s_unk_D43AF8;
|
||||
|
||||
// STATIC: 0x00D43AFC
|
||||
int32_t Liquid::s_unk_D43AFC;
|
||||
|
||||
// STATIC: 0x00D43B14
|
||||
TSGrowableArray<Liquid::CMaterialSettings*> Liquid::CSettingsBank::s_settings;
|
||||
|
||||
// STATIC: 0x00D43B48
|
||||
uint8_t Liquid::s_unk_D43B48[4];
|
||||
|
||||
// STATIC: 0x00D43B4C
|
||||
CTexture* Liquid::s_unk_D43B4C;
|
||||
|
||||
// STATIC: 0x00D43B50
|
||||
CTexture* Liquid::s_unk_D43B50[32];
|
||||
|
||||
// STATIC: 0x00D43BD0
|
||||
CTexture* Liquid::s_wmoWaterTex;
|
||||
|
||||
// STATIC: 0x00D43BD4
|
||||
CTexture* Liquid::s_oceanDepthTex;
|
||||
|
||||
// STATIC: 0x00D43BD8
|
||||
CTexture* Liquid::s_riverDepthTex;
|
||||
|
||||
// VERIFY: fb13c55c auto
|
||||
// OFFSET: 0x008A1770
|
||||
int32_t Liquid::Initialize(int32_t a1, float a2, int32_t a3, const char* a4, IDatabase<LiquidTypeRec>* liquidTypeDB, IDatabase<LiquidMaterialRec>* liquidMaterialDB) {
|
||||
SStrCopy(Liquid::s_unk_D439F0, a4, sizeof(Liquid::s_unk_D439F0));
|
||||
Liquid::s_unk_B23F64 = a2;
|
||||
Liquid::s_unk_D43AF8++;
|
||||
Liquid::s_unk_D43AFC++;
|
||||
Liquid::s_unk_D43AF4 = a1;
|
||||
Liquid::s_unk_D43AF0 = a3;
|
||||
Liquid::s_unk_B23F68 = 1;
|
||||
Liquid::s_liquidTypeDB = liquidTypeDB;
|
||||
Liquid::s_liquidMaterialDB = liquidMaterialDB;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: 2a7eaf1c manual
|
||||
// OFFSET: 0x008A2780
|
||||
void Liquid::CSettingsBank::ResetTextures() {
|
||||
for (uint32_t i = 0; i < Liquid::CSettingsBank::s_settings.Count(); i++) {
|
||||
if (Liquid::CSettingsBank::s_settings[i]) {
|
||||
Liquid::CSettingsBank::s_settings[i]->Destroy();
|
||||
Liquid::CSettingsBank::s_settings[i]->InitTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: bbba7190 auto
|
||||
// OFFSET: 0x008A2A10
|
||||
void Liquid::CacheProceduralTextures() {
|
||||
CGxTexFlags flags;
|
||||
|
||||
TextureCacheNewTexture(Liquid::s_riverDepthTex);
|
||||
TextureCacheNewTexture(Liquid::s_oceanDepthTex);
|
||||
TextureCacheNewTexture(Liquid::s_wmoWaterTex);
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(Liquid::s_unk_D43B50) / sizeof(Liquid::s_unk_D43B50[0]); i++) {
|
||||
if (Liquid::s_unk_D43B50[i]) {
|
||||
TextureCacheNewTexture(Liquid::s_unk_D43B50[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Liquid::s_unk_D43B4C) {
|
||||
TextureCacheNewTexture(Liquid::s_unk_D43B4C);
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::ResetTextures();
|
||||
}
|
||||
|
||||
// VERIFY: 5d576297 auto
|
||||
// OFFSET: 0x008A2E20
|
||||
void Liquid::CreateProceduralTextures() {
|
||||
Liquid::s_unk_D43B48[3] = 0;
|
||||
Liquid::s_unk_D43B48[2] = 0;
|
||||
Liquid::s_unk_D43B48[1] = 0;
|
||||
Liquid::s_unk_D43B48[0] = 0;
|
||||
|
||||
CGxTexFlags flags;
|
||||
Liquid::s_riverDepthTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, reinterpret_cast<void*>(1), Liquid::ExtWaterDepthTexCallback, "proceduralRiverDepthTex", 0);
|
||||
|
||||
flags = CGxTexFlags();
|
||||
Liquid::s_oceanDepthTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, nullptr, Liquid::ExtWaterDepthTexCallback, "proceduralOceanDepthTex", 0);
|
||||
|
||||
flags = CGxTexFlags();
|
||||
Liquid::s_wmoWaterTex = TextureCreate(8, 64, GxTex_Argb8888, GxTex_Argb8888, flags, nullptr, Liquid::WmoWaterTexCallback, "proceduralWmoWaterTex", 0);
|
||||
|
||||
Liquid::CacheProceduralTextures();
|
||||
}
|
||||
|
||||
// VERIFY: a171683e auto
|
||||
// OFFSET: 0x007D6670
|
||||
void Liquid::ClearWaveManagers() {
|
||||
Liquid::s_unk_D31A30.Clear(".?AVCWaveManager@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 36347972 auto
|
||||
// OFFSET: 0x007D47D0
|
||||
void Liquid::ClearGeomFactories() {
|
||||
Liquid::s_unk_D31960.Clear(".?AVCMeshGeomFactory@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D31974.Clear(".?AVCChunkGeomFactory@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: e3c196d2 auto
|
||||
// OFFSET: 0x007D5100
|
||||
void Liquid::ClearClientEnvironments() {
|
||||
Liquid::s_unk_D31A00.Clear(".?AVCClientEnvironment@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: c3031eda manual
|
||||
// OFFSET: 0x008A2400
|
||||
void Liquid::Shutdown() {
|
||||
int32_t count = Liquid::s_unk_D43AFC--;
|
||||
Liquid::s_liquidTypeDB = nullptr;
|
||||
Liquid::s_liquidMaterialDB = nullptr;
|
||||
|
||||
if (count == 1) {
|
||||
Liquid::CMaterialBank::Destroy();
|
||||
Liquid::s_unk_D43AF0 = 0;
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::Destroy();
|
||||
Liquid::ClearMaterials();
|
||||
Liquid::s_unk_D43B34.Clear(".?AVCInstance@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 901024cc manual
|
||||
// OFFSET: 0x008A2980
|
||||
void Liquid::DestroyProceduralTextures() {
|
||||
if (Liquid::s_unk_D43B4C) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_unk_D43B4C));
|
||||
Liquid::s_unk_D43B4C = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_riverDepthTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_riverDepthTex));
|
||||
Liquid::s_riverDepthTex = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_oceanDepthTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_oceanDepthTex));
|
||||
Liquid::s_oceanDepthTex = nullptr;
|
||||
}
|
||||
|
||||
if (Liquid::s_wmoWaterTex) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_wmoWaterTex));
|
||||
Liquid::s_wmoWaterTex = nullptr;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(Liquid::s_unk_D43B50) / sizeof(Liquid::s_unk_D43B50[0]); i++) {
|
||||
if (Liquid::s_unk_D43B50[i]) {
|
||||
HandleClose(reinterpret_cast<HOBJECT>(Liquid::s_unk_D43B50[i]));
|
||||
Liquid::s_unk_D43B50[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 44d8beb7 manual
|
||||
// OFFSET: 0x008A1F50
|
||||
void Liquid::CMaterialBank::Destroy() {
|
||||
for (uint32_t i = 0; i < Liquid::CMaterialBank::s_unk_D43B24.Count(); i++) {
|
||||
if (Liquid::CMaterialBank::s_unk_D43B24[i]) {
|
||||
Liquid::CMaterialBank::s_unk_D43B24[i]->Release();
|
||||
}
|
||||
}
|
||||
|
||||
Liquid::CMaterialBank::s_unk_D43B24.SetCount(0);
|
||||
}
|
||||
|
||||
// VERIFY: f4d601a2 manual
|
||||
// OFFSET: 0x008A2380
|
||||
void Liquid::CSettingsBank::Destroy() {
|
||||
if (!--Liquid::s_unk_D43AF8) {
|
||||
for (uint32_t i = 0; i < Liquid::CSettingsBank::s_settings.Count(); i++) {
|
||||
if (Liquid::CSettingsBank::s_settings[i]) {
|
||||
Liquid::CSettingsBank::s_settings[i]->Destroy();
|
||||
|
||||
Liquid::CMaterialSettings* settings = Liquid::CSettingsBank::s_settings[i];
|
||||
settings->~CMaterialSettings();
|
||||
Liquid::s_unk_D43B00.PutData(settings, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Liquid::CSettingsBank::s_settings.SetCount(0);
|
||||
}
|
||||
|
||||
Liquid::s_unk_D43B00.Clear(".?AVCMaterialSettings@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 502f2f3f auto
|
||||
// OFFSET: 0x008A4280
|
||||
void Liquid::ClearMaterials() {
|
||||
Liquid::s_unk_D45048.Clear(".?AVCMaterialProcWater@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D4505C.Clear(".?AVCMaterialProcWaterFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45070.Clear(".?AVCMaterialWater@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45084.Clear(".?AVCMaterialWaterNoSpec@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D45098.Clear(".?AVCMaterialWaterFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D450AC.Clear(".?AVCMaterialMagma@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D450C0.Clear(".?AVCMaterialMagmaFFP@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_LIQUID_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_LIQUID_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
|
||||
template <class T>
|
||||
class IDatabase;
|
||||
class CTexture;
|
||||
class LiquidMaterialRec;
|
||||
class LiquidTypeRec;
|
||||
|
||||
namespace Liquid {
|
||||
class CInstance;
|
||||
|
||||
class CRenderer {
|
||||
public:
|
||||
/* 0000 */ TSGrowableArray<CInstance*> unk_0000[2];
|
||||
|
||||
void Draw(CInstance* instance);
|
||||
};
|
||||
|
||||
class CMaterialSettings {
|
||||
public:
|
||||
~CMaterialSettings();
|
||||
void Destroy();
|
||||
void InitTexture();
|
||||
};
|
||||
|
||||
class CSettingsBank {
|
||||
public:
|
||||
static TSGrowableArray<CMaterialSettings*> s_settings;
|
||||
|
||||
static void Destroy();
|
||||
static void ResetTextures();
|
||||
};
|
||||
|
||||
class IMaterial {
|
||||
public:
|
||||
virtual ~IMaterial();
|
||||
virtual void Release();
|
||||
};
|
||||
|
||||
class CMaterialBank {
|
||||
public:
|
||||
static TSGrowableArray<IMaterial*> s_unk_D43B24;
|
||||
|
||||
static void Destroy();
|
||||
};
|
||||
|
||||
extern CDataAllocator s_unk_D31960;
|
||||
extern CDataAllocator s_unk_D31974;
|
||||
extern CDataAllocator s_unk_D31A00;
|
||||
extern CDataAllocator s_unk_D31A30;
|
||||
extern CDataAllocator s_unk_D43B00;
|
||||
extern CDataAllocator s_unk_D43B34;
|
||||
extern CDataAllocator s_unk_D45048;
|
||||
extern CDataAllocator s_unk_D4505C;
|
||||
extern CDataAllocator s_unk_D45070;
|
||||
extern CDataAllocator s_unk_D45084;
|
||||
extern CDataAllocator s_unk_D45098;
|
||||
extern CDataAllocator s_unk_D450AC;
|
||||
extern CDataAllocator s_unk_D450C0;
|
||||
extern float s_unk_B23F64;
|
||||
extern int32_t s_unk_B23F68;
|
||||
extern IDatabase<LiquidMaterialRec>* s_liquidMaterialDB;
|
||||
extern IDatabase<LiquidTypeRec>* s_liquidTypeDB;
|
||||
extern char s_unk_D439F0[256];
|
||||
extern int32_t s_unk_D43AF0;
|
||||
extern int32_t s_unk_D43AF4;
|
||||
extern int32_t s_unk_D43AF8;
|
||||
extern int32_t s_unk_D43AFC;
|
||||
extern uint8_t s_unk_D43B48[4];
|
||||
extern CTexture* s_unk_D43B4C;
|
||||
extern CTexture* s_unk_D43B50[32];
|
||||
extern CTexture* s_wmoWaterTex;
|
||||
extern CTexture* s_oceanDepthTex;
|
||||
extern CTexture* s_riverDepthTex;
|
||||
|
||||
void CacheProceduralTextures();
|
||||
void ClearClientEnvironments();
|
||||
void ClearGeomFactories();
|
||||
void ClearMaterials();
|
||||
void ClearWaveManagers();
|
||||
void CreateProceduralTextures();
|
||||
void DestroyProceduralTextures();
|
||||
void ExtWaterDepthTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
int32_t Initialize(int32_t a1, float a2, int32_t a3, const char* a4, IDatabase<LiquidTypeRec>* liquidTypeDB, IDatabase<LiquidMaterialRec>* liquidMaterialDB);
|
||||
void Shutdown();
|
||||
void WmoWaterTexCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "LiquidEnvironment.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Model2/M2Scene.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapLight.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
|
||||
// STATIC: 0x00D31A00
|
||||
CDataAllocator Liquid::s_unk_D31A00(0xC, 0x10);
|
||||
|
||||
// VERIFY: e3c196d2 auto
|
||||
// OFFSET: 0x007D5100
|
||||
void Liquid::ClearClientEnvironments() {
|
||||
Liquid::s_unk_D31A00.Clear(".?AVCClientEnvironment@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 5ea0339f auto
|
||||
// OFFSET: 0x007D4F10
|
||||
void Liquid::CClientEnvironment::SetInteriorFog(int32_t interiorFog) {
|
||||
this->m_interiorFog = interiorFog;
|
||||
}
|
||||
|
||||
// VERIFY: 442bf5b9 auto
|
||||
// OFFSET: 0x007D4F20
|
||||
void Liquid::CClientEnvironment::Release() {
|
||||
this->~CClientEnvironment();
|
||||
Liquid::s_unk_D31A00.PutData(this, nullptr, 0);
|
||||
}
|
||||
|
||||
// VERIFY: 2a7d5c2c manual
|
||||
// OFFSET: 0x007D4F40
|
||||
void Liquid::CClientEnvironment::SelectLights(CM2Lighting* lighting) {
|
||||
DayNight::DNInfo* dayNight = DayNight::GetInfo();
|
||||
|
||||
C3Vector fogColor;
|
||||
float fogStart;
|
||||
float fogEnd;
|
||||
float fogDensity;
|
||||
|
||||
if (this->m_interiorFog) {
|
||||
fogColor = C3Vector(dayNight->m_fogInterior.m_color);
|
||||
fogDensity = dayNight->m_fogInterior.m_density;
|
||||
fogEnd = dayNight->m_fogInterior.m_end;
|
||||
fogStart = dayNight->m_fogInterior.m_start;
|
||||
} else {
|
||||
fogColor = C3Vector(dayNight->m_fog.m_color);
|
||||
fogDensity = dayNight->m_fog.m_density;
|
||||
fogEnd = dayNight->m_fog.m_end;
|
||||
fogStart = dayNight->m_fog.m_start;
|
||||
}
|
||||
|
||||
lighting->SetFog(fogColor, fogStart, fogEnd, fogDensity);
|
||||
|
||||
if (this->m_customLight) {
|
||||
static CM2Light s_light;
|
||||
static int32_t s_lightInitialized;
|
||||
|
||||
if (!s_lightInitialized) {
|
||||
s_light.SetLightType(M2LIGHT_DIRECT);
|
||||
s_light.m_constantAttenuation = 1.0f;
|
||||
s_light.m_linearAttenuation = 0.0f;
|
||||
s_light.m_quadraticAttenuation = 0.0f;
|
||||
s_light.SetDirection(C3Vector(0.0f, 0.0f, -1.0f));
|
||||
s_light.m_dirColor = C3Vector(1.0f, 1.0f, 1.0f);
|
||||
s_light.SetVisible(1);
|
||||
s_lightInitialized = 1;
|
||||
}
|
||||
|
||||
lighting->AddLight(&s_light);
|
||||
} else {
|
||||
lighting->AddLight(&CMap::s_mapLight->m_light);
|
||||
}
|
||||
|
||||
World::s_m2Scene->SelectLights(lighting);
|
||||
}
|
||||
|
||||
// VERIFY: 83664886 auto
|
||||
// OFFSET: 0x007D5120
|
||||
Liquid::CClientEnvironment* Liquid::CClientEnvironment::Create(int32_t customLight) {
|
||||
void* mem = Liquid::s_unk_D31A00.GetData(0, ".?AVCClientEnvironment@Liquid@@", SLOG_OBJECT);
|
||||
Liquid::CClientEnvironment* environment = mem ? new (mem) Liquid::CClientEnvironment() : nullptr;
|
||||
environment->m_interiorFog = 0;
|
||||
environment->m_customLight = customLight;
|
||||
|
||||
return environment;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_LIQUIDENVIRONMENT_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_LIQUIDENVIRONMENT_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
|
||||
class CM2Lighting;
|
||||
|
||||
namespace Liquid {
|
||||
class CClientEnvironment : public IEnvironment {
|
||||
public:
|
||||
static CClientEnvironment* Create(int32_t customLight);
|
||||
|
||||
/* 0004 */ int32_t m_interiorFog;
|
||||
/* 0008 */ int32_t m_customLight;
|
||||
|
||||
virtual void Release();
|
||||
virtual void SetInteriorFog(int32_t interiorFog);
|
||||
virtual void SelectLights(CM2Lighting* lighting);
|
||||
};
|
||||
|
||||
extern CDataAllocator s_unk_D31A00;
|
||||
|
||||
void ClearClientEnvironments();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,337 @@
|
||||
#include "LiquidGeomFactories.h"
|
||||
#include "Engine/Source/Gx/CGxBuf.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/WorldClient/CChunkLiquid.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/MapChunkLiquid.h"
|
||||
#include "WoW/Source/WorldClient/MapObj.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
|
||||
// STATIC: 0x00D31960
|
||||
CDataAllocator Liquid::s_unk_D31960(0x48, 4);
|
||||
|
||||
// STATIC: 0x00D31974
|
||||
CDataAllocator Liquid::s_unk_D31974(0x74, 0x10);
|
||||
|
||||
// VERIFY: 36347972 auto
|
||||
// OFFSET: 0x007D47D0
|
||||
void Liquid::ClearGeomFactories() {
|
||||
Liquid::s_unk_D31960.Clear(".?AVCMeshGeomFactory@Liquid@@", SLOG_OBJECT, 1);
|
||||
Liquid::s_unk_D31974.Clear(".?AVCChunkGeomFactory@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 32ee76a0 manual
|
||||
// OFFSET: 0x007D4380
|
||||
void Liquid::CMeshGeomFactory::Purge() {
|
||||
if (this->m_mapObjGroup) {
|
||||
this->m_mapObjGroup->FreeLiquidVB();
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2fdfe76c auto
|
||||
// OFFSET: 0x007D4390
|
||||
void Liquid::CChunkGeomFactory::Purge() {
|
||||
if (this->m_buf) {
|
||||
CMapChunkLiquidBuf::Free(this->m_buf);
|
||||
this->m_buf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: a06cee34 manual
|
||||
// OFFSET: 0x007D43B0
|
||||
void Liquid::CMeshGeomFactory::Release() {
|
||||
if (this->m_refCount-- == 1) {
|
||||
this->~CMeshGeomFactory();
|
||||
Liquid::s_unk_D31960.PutData(this, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 606bea00 manual
|
||||
// OFFSET: 0x007D4760
|
||||
void Liquid::CChunkGeomFactory::Release() {
|
||||
if (this->m_refCount-- == 1) {
|
||||
this->~CChunkGeomFactory();
|
||||
Liquid::s_unk_D31974.PutData(this, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: de869a00 manual
|
||||
// OFFSET: 0x007D4790
|
||||
bool Liquid::CChunkGeomFactory::SetTransform(C44Matrix* transform) {
|
||||
if (this->m_transform == *transform) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this->m_transform = *transform;
|
||||
this->m_dirty = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// VERIFY: 1be8aa58 manual
|
||||
// OFFSET: 0x007D43F0
|
||||
void Liquid::CMeshGeomFactory::GetBuffers(EGxVertexBufferFormat format, CGxBuf** vertexBuf, CGxBuf** indexBuf, CGxBatch* batch) {
|
||||
if (static_cast<uint16_t>(this->m_mapObjGroup->m_luquidMaterialId) >= static_cast<uint32_t>(this->m_mapObj->m_materialsCount)) {
|
||||
SErrDisplayAppFatal("Water in chunk \"%s\" of object \"%s\" has no materialId.", this->m_mapObjGroup->m_groupName, this->m_mapObj->m_wmoName);
|
||||
}
|
||||
|
||||
uint32_t sharedCols = this->m_sharedVerts[0].m_count;
|
||||
uint32_t sharedRows = this->m_sharedVerts[1].m_count;
|
||||
uint32_t sharedTiles = this->m_mapObjGroup->GetNumSharedTiles();
|
||||
uint32_t vertexCount = (sharedRows + this->m_mapObjGroup->m_liquidVerts.y) * (sharedCols + this->m_mapObjGroup->m_liquidVerts.x) + 6 * sharedTiles;
|
||||
this->m_mapObjGroup->AllocLiquidVB(format, vertexCount, 3 * vertexCount, &this->m_batch);
|
||||
|
||||
*vertexBuf = this->m_mapObjGroup->m_liquidVertsBlock->m_buffer;
|
||||
*indexBuf = this->m_mapObjGroup->m_liquidIndicesBlock->m_buffer;
|
||||
|
||||
if (!(*vertexBuf)->unk_001C || !(*vertexBuf)->unk_001D || !(*indexBuf)->unk_001C || !(*indexBuf)->unk_001D) {
|
||||
char* vertices = g_theGxDevicePtr->BufLock(*vertexBuf);
|
||||
uint16_t* indices = reinterpret_cast<uint16_t*>(g_theGxDevicePtr->BufLock(*indexBuf));
|
||||
uint16_t* indexStart = indices;
|
||||
|
||||
if (!vertices || !indices) {
|
||||
if (vertices) {
|
||||
CGxBuf* buf = *vertexBuf;
|
||||
g_theGxDevicePtr->BufUnlock(buf, 0);
|
||||
buf->unk_001C = 1;
|
||||
}
|
||||
|
||||
if (indices) {
|
||||
CGxBuf* buf = *indexBuf;
|
||||
g_theGxDevicePtr->BufUnlock(buf, 0);
|
||||
buf->unk_001C = 1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t stride = GxVertexSize(format);
|
||||
C3Vector* position = reinterpret_cast<C3Vector*>(vertices + GxVertexAttribOffset(format, GxVA_Position));
|
||||
C3Vector* normal = nullptr;
|
||||
CImVector* color = nullptr;
|
||||
C2Vector* texCoord0 = nullptr;
|
||||
C2Vector* texCoord1 = nullptr;
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_Normal)) {
|
||||
normal = reinterpret_cast<C3Vector*>(vertices + GxVertexAttribOffset(format, GxVA_Normal));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_Color0)) {
|
||||
color = reinterpret_cast<CImVector*>(vertices + GxVertexAttribOffset(format, GxVA_Color0));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_TexCoord0)) {
|
||||
texCoord0 = reinterpret_cast<C2Vector*>(vertices + GxVertexAttribOffset(format, GxVA_TexCoord0));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_TexCoord1)) {
|
||||
texCoord1 = reinterpret_cast<C2Vector*>(vertices + GxVertexAttribOffset(format, GxVA_TexCoord1));
|
||||
}
|
||||
|
||||
const CImVector* liquidColor = reinterpret_cast<const CImVector*>(&this->unk_0014);
|
||||
uint16_t count = this->m_mapObj->BuildLiquidVerts(this->m_mapObjGroup, C44Matrix(), liquidColor, this->unk_001C, this->unk_0020, this->m_sharedVerts, stride, &position, &normal, &color, &texCoord0, &texCoord1);
|
||||
this->m_mapObj->BuildLiquidIndices(this->m_mapObjGroup, this->m_sharedVerts, &indices, 0);
|
||||
count += this->m_mapObj->ClipGroupGeometry(this->m_mapObjGroup, C44Matrix(), liquidColor, this->unk_001C, this->unk_0020, stride, &position, &normal, &color, &texCoord0, &texCoord1, &indices, count);
|
||||
|
||||
CGxBuf* buf = *vertexBuf;
|
||||
g_theGxDevicePtr->BufUnlock(buf, 0);
|
||||
buf->unk_001C = 1;
|
||||
|
||||
if (indices) {
|
||||
buf = *indexBuf;
|
||||
g_theGxDevicePtr->BufUnlock(buf, 0);
|
||||
buf->unk_001C = 1;
|
||||
}
|
||||
|
||||
CGxBatch* meshBatch = this->m_batch;
|
||||
meshBatch->m_primType = GxPrim_TriangleStrip;
|
||||
meshBatch->m_start = 0;
|
||||
meshBatch->m_count = indices - indexStart;
|
||||
meshBatch->m_minIndex = 0;
|
||||
meshBatch->m_maxIndex = count - 1;
|
||||
}
|
||||
|
||||
*batch = *this->m_batch;
|
||||
}
|
||||
|
||||
// VERIFY: ac0e5a30 manual
|
||||
// OFFSET: 0x007D4800
|
||||
Liquid::CMeshGeomFactory::~CMeshGeomFactory() {
|
||||
if (this->m_mapObjGroup) {
|
||||
this->m_mapObjGroup->FreeLiquidVB();
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2528fd80 manual
|
||||
// OFFSET: 0x007D4850
|
||||
Liquid::CChunkGeomFactory::CChunkGeomFactory() {
|
||||
this->m_refCount = 1;
|
||||
this->m_dirty = 1;
|
||||
this->m_buf = nullptr;
|
||||
this->m_batch.m_primType = GxPrims_Last;
|
||||
this->m_batch.m_start = 0;
|
||||
this->m_batch.m_count = 0;
|
||||
this->m_batch.m_minIndex = 0;
|
||||
this->m_batch.m_maxIndex = 0;
|
||||
}
|
||||
|
||||
// VERIFY: ae53ab8b manual
|
||||
// OFFSET: 0x007D48C0
|
||||
Liquid::CChunkGeomFactory::~CChunkGeomFactory() {
|
||||
if (this->m_buf) {
|
||||
CMapChunkLiquidBuf::Free(this->m_buf);
|
||||
this->m_buf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// INLINED
|
||||
Liquid::CMeshGeomFactory::CMeshGeomFactory() {
|
||||
this->m_refCount = 1;
|
||||
this->m_mapObj = nullptr;
|
||||
this->m_mapObjGroup = nullptr;
|
||||
this->m_batch = nullptr;
|
||||
this->unk_0014 = -1;
|
||||
this->unk_0020 = 0.0f;
|
||||
this->unk_001C = 0;
|
||||
this->unk_0024 = 0;
|
||||
}
|
||||
|
||||
// VERIFY: c7ce1eb1 auto
|
||||
// OFFSET: 0x007D49B0
|
||||
Liquid::CMeshGeomFactory* Liquid::CMeshGeomFactory::Create(CMapObj* mapObj, CMapObjGroup* mapObjGroup) {
|
||||
Liquid::CMeshGeomFactory* factory = Liquid::s_unk_D31960.New<Liquid::CMeshGeomFactory>(0);
|
||||
factory->m_mapObj = mapObj;
|
||||
factory->m_mapObjGroup = mapObjGroup;
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
// VERIFY: 1a3ea7df manual
|
||||
// OFFSET: 0x007D49D0
|
||||
Liquid::CChunkGeomFactory* Liquid::CChunkGeomFactory::Create(const TSGrowableArray<CChunkLiquid*>& chunks) {
|
||||
void* mem = Liquid::s_unk_D31974.GetData(0, ".?AVCChunkGeomFactory@Liquid@@", SLOG_OBJECT);
|
||||
Liquid::CChunkGeomFactory* factory = mem ? new (mem) Liquid::CChunkGeomFactory() : nullptr;
|
||||
|
||||
for (uint32_t i = 0; i < chunks.m_count; i++) {
|
||||
factory->m_chunks.New(chunks.m_data[i]);
|
||||
}
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
// VERIFY: bb721706 manual
|
||||
// OFFSET: 0x007D4AB0
|
||||
void Liquid::CChunkGeomFactory::GetBuffers(EGxVertexBufferFormat format, CGxBuf** vertexBuf, CGxBuf** indexBuf, CGxBatch* batch) {
|
||||
if (this->m_buf && this->m_buf->Valid() && !this->m_dirty) {
|
||||
*vertexBuf = this->m_buf->m_vertexBuf;
|
||||
*indexBuf = this->m_buf->m_indexBuf;
|
||||
*batch = this->m_batch;
|
||||
return;
|
||||
}
|
||||
|
||||
static TSGrowableArray<uint16_t> s_vertexCounts;
|
||||
|
||||
s_vertexCounts.Clear();
|
||||
|
||||
uint32_t vertexCount = 0;
|
||||
uint32_t indexCount = 0;
|
||||
|
||||
for (uint32_t i = 0; i < this->m_chunks.m_count; i++) {
|
||||
CChunkLiquid* liquid = this->m_chunks.m_data[i];
|
||||
uint16_t cols = liquid->m_tileEnd.y - liquid->m_tileBegin.y;
|
||||
uint16_t rows = liquid->m_tileEnd.x - liquid->m_tileBegin.x;
|
||||
uint16_t count = (cols + 1) * (rows + 1);
|
||||
s_vertexCounts.New(count);
|
||||
vertexCount += count;
|
||||
indexCount += 6 * cols * rows;
|
||||
}
|
||||
|
||||
if (!this->m_buf) {
|
||||
this->m_buf = CMapChunkLiquidBuf::Alloc(vertexCount, indexCount, 0, format);
|
||||
}
|
||||
|
||||
*vertexBuf = this->m_buf->m_vertexBuf;
|
||||
*indexBuf = this->m_buf->m_indexBuf;
|
||||
|
||||
if (this->m_dirty) {
|
||||
(*vertexBuf)->unk_001C = 0;
|
||||
(*indexBuf)->unk_001C = 0;
|
||||
}
|
||||
|
||||
CGxBuf* vb = *vertexBuf;
|
||||
|
||||
if (!vb->unk_001C || !vb->unk_001D) {
|
||||
char* data = g_theGxDevicePtr->BufLock(vb);
|
||||
|
||||
if (data) {
|
||||
uint32_t stride = GxVertexSize(format);
|
||||
C3Vector* position = reinterpret_cast<C3Vector*>(data + GxVertexAttribOffset(format, GxVA_Position));
|
||||
C3Vector* normal = nullptr;
|
||||
uint32_t* color = nullptr;
|
||||
C2Vector* texCoord0 = nullptr;
|
||||
C2Vector* texCoord1 = nullptr;
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_Normal)) {
|
||||
normal = reinterpret_cast<C3Vector*>(data + GxVertexAttribOffset(format, GxVA_Normal));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_Color0)) {
|
||||
color = reinterpret_cast<uint32_t*>(data + GxVertexAttribOffset(format, GxVA_Color0));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_TexCoord0)) {
|
||||
texCoord0 = reinterpret_cast<C2Vector*>(data + GxVertexAttribOffset(format, GxVA_TexCoord0));
|
||||
}
|
||||
|
||||
if (GxVertexHasAttrib(format, GxVA_TexCoord1)) {
|
||||
texCoord1 = reinterpret_cast<C2Vector*>(data + GxVertexAttribOffset(format, GxVA_TexCoord1));
|
||||
}
|
||||
|
||||
CChunkLiquid* first = this->m_chunks.m_data[0];
|
||||
|
||||
for (uint32_t i = 0; i < this->m_chunks.m_count; i++) {
|
||||
CChunkLiquid* liquid = this->m_chunks.m_data[i];
|
||||
C44Matrix transform = this->m_transform;
|
||||
C3Vector offset(liquid->m_topLeftCoords.x - first->m_topLeftCoords.x, liquid->m_topLeftCoords.y - first->m_topLeftCoords.y, liquid->m_topLeftCoords.z - first->m_topLeftCoords.z);
|
||||
transform.Translate(offset);
|
||||
liquid->BuildVertices(&transform, stride, &position, &normal, &color, &texCoord1, &texCoord0);
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->BufUnlock(vb, 0);
|
||||
vb->unk_001C = 1;
|
||||
}
|
||||
}
|
||||
|
||||
CGxBuf* ib = *indexBuf;
|
||||
|
||||
if (!ib->unk_001C || !ib->unk_001D) {
|
||||
batch->m_primType = GxPrim_TriangleStrip;
|
||||
batch->m_start = 0;
|
||||
batch->m_count = 0;
|
||||
batch->m_minIndex = 0;
|
||||
batch->m_maxIndex = vertexCount - 1;
|
||||
|
||||
uint16_t* indices = reinterpret_cast<uint16_t*>(g_theGxDevicePtr->BufLock(ib));
|
||||
uint16_t baseVertex = 0;
|
||||
|
||||
for (uint32_t i = 0; i < this->m_chunks.m_count; i++) {
|
||||
this->m_chunks.m_data[i]->BuildIndices(indices + batch->m_count, baseVertex, batch);
|
||||
baseVertex += s_vertexCounts.m_data[i];
|
||||
}
|
||||
|
||||
g_theGxDevicePtr->BufUnlock(ib, 0);
|
||||
ib->unk_001C = 1;
|
||||
this->m_batch = *batch;
|
||||
}
|
||||
|
||||
this->m_format = format;
|
||||
this->m_dirty = 0;
|
||||
}
|
||||
|
||||
// VERIFY: b01df36e auto
|
||||
// OFFSET: 0x008813A0
|
||||
bool Liquid::CMeshGeomFactory::SetTransform(C44Matrix* transform) {
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_LIQUIDGEOMFACTORIES_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_LIQUIDGEOMFACTORIES_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
|
||||
class CChunkLiquid;
|
||||
class CMapChunkLiquidBuf;
|
||||
class CMapObj;
|
||||
class CMapObjGroup;
|
||||
|
||||
namespace Liquid {
|
||||
class CChunkGeomFactory : public IGeomFactory {
|
||||
public:
|
||||
static CChunkGeomFactory* Create(const TSGrowableArray<CChunkLiquid*>& chunks);
|
||||
|
||||
/* 0004 */ int32_t m_refCount;
|
||||
/* 0008 */ int32_t m_dirty;
|
||||
/* 000C */ TSGrowableArray<CChunkLiquid*> m_chunks;
|
||||
/* 001C */ CMapChunkLiquidBuf* m_buf;
|
||||
/* 0020 */ CGxBatch m_batch;
|
||||
/* 0030 */ EGxVertexBufferFormat m_format;
|
||||
/* 0034 */ C44Matrix m_transform;
|
||||
|
||||
virtual ~CChunkGeomFactory();
|
||||
virtual void Release();
|
||||
virtual void GetBuffers(EGxVertexBufferFormat format, CGxBuf** vertexBuf, CGxBuf** indexBuf, CGxBatch* batch);
|
||||
virtual void Purge();
|
||||
virtual bool SetTransform(C44Matrix* transform);
|
||||
|
||||
CChunkGeomFactory();
|
||||
};
|
||||
|
||||
class CMeshGeomFactory : public IGeomFactory {
|
||||
public:
|
||||
static CMeshGeomFactory* Create(CMapObj* mapObj, CMapObjGroup* mapObjGroup);
|
||||
|
||||
/* 0004 */ int32_t m_refCount;
|
||||
/* 0008 */ CMapObj* m_mapObj;
|
||||
/* 000C */ CMapObjGroup* m_mapObjGroup;
|
||||
/* 0010 */ CGxBatch* m_batch;
|
||||
/* 0014 */ int32_t unk_0014;
|
||||
/* 0018 */ int32_t unk_0018;
|
||||
/* 001C */ int32_t unk_001C;
|
||||
/* 0020 */ float unk_0020;
|
||||
/* 0024 */ int32_t unk_0024;
|
||||
/* 0028 */ TSGrowableArray<uint8_t> m_sharedVerts[2];
|
||||
|
||||
virtual ~CMeshGeomFactory();
|
||||
virtual void Release();
|
||||
virtual void GetBuffers(EGxVertexBufferFormat format, CGxBuf** vertexBuf, CGxBuf** indexBuf, CGxBatch* batch);
|
||||
virtual void Purge();
|
||||
virtual bool SetTransform(C44Matrix* transform);
|
||||
|
||||
CMeshGeomFactory();
|
||||
};
|
||||
|
||||
extern CDataAllocator s_unk_D31960;
|
||||
extern CDataAllocator s_unk_D31974;
|
||||
|
||||
void ClearGeomFactories();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,169 @@
|
||||
#include "LiquidWaveManager.h"
|
||||
#include <cstring>
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/FrameTime.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
|
||||
// STATIC: 0x00D31A30
|
||||
CDataAllocator Liquid::s_unk_D31A30(0x128, 0x10);
|
||||
|
||||
// STATIC: 0x00AF1690
|
||||
float Liquid::CWaveManager::s_fadeOutTime = 5000.0f;
|
||||
|
||||
// STATIC: 0x00AF1694
|
||||
float Liquid::CWaveManager::s_fadeInTime = 5000.0f;
|
||||
|
||||
// VERIFY: ba8e6430 manual
|
||||
// OFFSET: 0x007D62A0
|
||||
void Liquid::CWaveManager::PrepareRenderTransform(const C3Vector* camPos) {
|
||||
static int32_t s_lastFrame;
|
||||
|
||||
if (s_lastFrame == CWorld::frameCnt) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_lastFrame = CWorld::frameCnt;
|
||||
|
||||
static uint32_t s_lastTime = FrameTime::s_curTimeMs;
|
||||
uint32_t elapsed = FrameTime::s_curTimeMs - s_lastTime;
|
||||
s_lastTime = FrameTime::s_curTimeMs;
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
float time = elapsed + this->m_time[i];
|
||||
this->m_time[i] = time;
|
||||
|
||||
float fadeIn = time / Liquid::CWaveManager::s_fadeInTime;
|
||||
|
||||
if (fadeIn > 1.0f) {
|
||||
fadeIn = 1.0f;
|
||||
}
|
||||
|
||||
float fadeOut;
|
||||
|
||||
if (time >= this->m_duration[i]) {
|
||||
fadeOut = 0.0f;
|
||||
} else {
|
||||
fadeOut = (this->m_duration[i] - time) / Liquid::CWaveManager::s_fadeOutTime;
|
||||
|
||||
if (fadeOut > 1.0f) {
|
||||
fadeOut = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float fade = fadeOut <= fadeIn ? fadeOut : fadeIn;
|
||||
|
||||
if (fade < 0.0f) {
|
||||
fade = 0.0f;
|
||||
}
|
||||
|
||||
this->m_data.m_waves[i].m_amplitude = fade * this->m_waves[i].m_amplitude;
|
||||
|
||||
if (this->m_time[i] >= this->m_duration[i]) {
|
||||
SWave& wave = this->m_waves[i];
|
||||
|
||||
this->m_time[i] = 0.0f;
|
||||
this->m_duration[i] = static_cast<float>(rand() % 20000 + 20000);
|
||||
|
||||
C3Vector* target = CWorldScene::GetCamTarget();
|
||||
float toTargetX = target->x - camPos->x;
|
||||
float toTargetY = target->y - camPos->y;
|
||||
float toTargetZ = target->z - camPos->z;
|
||||
float lengthSq = toTargetZ * toTargetZ + toTargetX * toTargetX + toTargetY * toTargetY;
|
||||
|
||||
if (lengthSq > 0.00000023841858f) {
|
||||
float inv = 1.0f / sqrtf(lengthSq);
|
||||
toTargetX = toTargetX * inv;
|
||||
toTargetY = inv * toTargetY;
|
||||
}
|
||||
|
||||
float distX = (rand() % 50 + 150.0f) * toTargetX;
|
||||
float x = (rand() % 100 - 50) + camPos->x + distX;
|
||||
float distY = (rand() % 50 + 150.0f) * toTargetY;
|
||||
float y = (rand() % 100 - 50) + distY + camPos->y;
|
||||
wave.m_x = x;
|
||||
wave.m_y = y;
|
||||
|
||||
float dirX = camPos->x - x;
|
||||
float dirY = camPos->y - y;
|
||||
float dirLengthSq = dirX * dirX + dirY * dirY;
|
||||
|
||||
if (dirLengthSq > 0.00000023841858f) {
|
||||
float inv = 1.0f / sqrtf(dirLengthSq);
|
||||
dirX = dirX * inv;
|
||||
dirY = dirY * inv;
|
||||
}
|
||||
|
||||
C44Matrix rotation;
|
||||
rotation.RotateAroundZ((rand() % 2000 - 1000.0f) * 0.00078539818f);
|
||||
C3Vector dir = C3Vector(dirX, dirY, 0.0f) * rotation;
|
||||
wave.m_dirX = dir.x;
|
||||
wave.m_dirY = dir.y;
|
||||
|
||||
wave.m_speed = (rand() % 1000) * 0.039999999f + 10.0f;
|
||||
wave.m_length = (rand() % 1000) * 0.2f + 200.0f;
|
||||
wave.m_amplitude = (rand() % 1000) * 0.00050000002f + 0.5f;
|
||||
wave.unk_001C = (rand() % 1000) * 0.000030000001f + 0.02f;
|
||||
|
||||
this->m_data.m_waves[i] = wave;
|
||||
this->m_data.m_waves[i].m_amplitude = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: a171683e auto
|
||||
// OFFSET: 0x007D6670
|
||||
void Liquid::ClearWaveManagers() {
|
||||
Liquid::s_unk_D31A30.Clear(".?AVCWaveManager@Liquid@@", SLOG_OBJECT, 1);
|
||||
}
|
||||
|
||||
// VERIFY: 845a53cd auto
|
||||
// OFFSET: 0x00530B70
|
||||
void Liquid::CWaveManager::AddRef() {
|
||||
this->m_refCount++;
|
||||
}
|
||||
|
||||
// VERIFY: bd870ef6 auto
|
||||
// OFFSET: 0x007D6200
|
||||
int32_t Liquid::CWaveManager::GetCount() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
// VERIFY: 0b2c6ff5 manual
|
||||
// OFFSET: 0x007D6210
|
||||
void Liquid::CWaveManager::Release() {
|
||||
if (this->m_refCount-- == 1) {
|
||||
this->~CWaveManager();
|
||||
Liquid::s_unk_D31A30.PutData(this, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: e6866435 manual
|
||||
// OFFSET: 0x007D6240
|
||||
Liquid::CWaveManager::CWaveManager() {
|
||||
this->m_refCount = 1;
|
||||
memset(&this->m_data, 0, sizeof(this->m_data));
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
this->m_time[i] = 0.0f;
|
||||
this->m_duration[i] = 0.0f;
|
||||
}
|
||||
|
||||
memset(this->m_waves, 0, sizeof(this->m_waves));
|
||||
}
|
||||
|
||||
// VERIFY: 66640799 auto
|
||||
// OFFSET: 0x007D6640
|
||||
Liquid::CWaveManager* Liquid::CWaveManager::Create() {
|
||||
void* mem = Liquid::s_unk_D31A30.GetData(0, ".?AVCWaveManager@Liquid@@", SLOG_OBJECT);
|
||||
return mem ? new (mem) Liquid::CWaveManager() : nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 79404128 auto
|
||||
// OFFSET: 0x008C6C80
|
||||
void* Liquid::CWaveManager::GetData() {
|
||||
return &this->m_data;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_LIQUIDWAVEMANAGER_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_LIQUIDWAVEMANAGER_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
|
||||
namespace Liquid {
|
||||
struct SWave {
|
||||
/* 0000 */ float m_x;
|
||||
/* 0004 */ float m_y;
|
||||
/* 0008 */ float m_dirX;
|
||||
/* 000C */ float m_dirY;
|
||||
/* 0010 */ float m_speed;
|
||||
/* 0014 */ float m_length;
|
||||
/* 0018 */ float m_amplitude;
|
||||
/* 001C */ float unk_001C;
|
||||
};
|
||||
|
||||
struct SWaveData {
|
||||
/* 0000 */ uint8_t unk_0000[72];
|
||||
/* 0048 */ SWave m_waves[3];
|
||||
};
|
||||
|
||||
class CWaveManager : public IWaveManager {
|
||||
public:
|
||||
static float s_fadeOutTime;
|
||||
static float s_fadeInTime;
|
||||
|
||||
static CWaveManager* Create();
|
||||
|
||||
/* 0004 */ int32_t m_refCount;
|
||||
/* 0008 */ SWaveData m_data;
|
||||
/* 00B0 */ float m_time[3];
|
||||
/* 00BC */ float m_duration[3];
|
||||
/* 00C8 */ SWave m_waves[3];
|
||||
|
||||
virtual void AddRef();
|
||||
virtual void Release();
|
||||
virtual void* GetData();
|
||||
virtual int32_t GetCount();
|
||||
|
||||
CWaveManager();
|
||||
void PrepareRenderTransform(const C3Vector* camPos);
|
||||
};
|
||||
|
||||
extern CDataAllocator s_unk_D31A30;
|
||||
|
||||
void ClearWaveManagers();
|
||||
}
|
||||
|
||||
#endif
|
||||
+2033
-3
File diff suppressed because it is too large
Load Diff
+174
-36
@@ -7,22 +7,43 @@
|
||||
#include "Engine/Source/Tempest/C4Quaternion.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Gx/CGxVertexPC.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/MapLowDetail.h"
|
||||
#include "WoW/Source/WorldClient/MapRenderChunk.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
|
||||
class C44Matrix;
|
||||
class CAaSphere;
|
||||
class CFacet;
|
||||
class CFrustum;
|
||||
class CM2Model;
|
||||
class CMapAreaTexture;
|
||||
class CMapBaseObj;
|
||||
class CMapBaseObjLink;
|
||||
class CMapChunk;
|
||||
class CMapDoodadDef;
|
||||
class CMapLight;
|
||||
class CMapObjDef;
|
||||
class CMapObjDefGroup;
|
||||
class CMapObjGroup;
|
||||
class CMapStaticEntity;
|
||||
class CiRect;
|
||||
class SFileImpl;
|
||||
class SFile;
|
||||
namespace World { class FacetData; }
|
||||
|
||||
struct CGxBuf;
|
||||
struct CGxPool;
|
||||
class CGxShader;
|
||||
class CChunkLiquid;
|
||||
class CMapArea;
|
||||
class FVBBList;
|
||||
class CMapAreaMed;
|
||||
class CMapEntity;
|
||||
class CTexture;
|
||||
|
||||
class CGxVertexPC {
|
||||
public:
|
||||
/* 0000 */ C3Vector m_p;
|
||||
/* 000C */ CImVector m_c;
|
||||
};
|
||||
struct SMMapHeader;
|
||||
|
||||
class CMapAreaEntry {
|
||||
public:
|
||||
@@ -80,8 +101,34 @@ class CMapFootprintTexture {
|
||||
CMapFootprintTexture();
|
||||
};
|
||||
|
||||
typedef int32_t (*MAP_OBJECT_FUNC)(void*, uint32_t, uint64_t, uint32_t);
|
||||
|
||||
struct MapObjIntersectData {
|
||||
/* 0000 */ CMapObjDef* def;
|
||||
/* 0004 */ CMapObjDefGroup* group;
|
||||
/* 0008 */ float t;
|
||||
/* 000C */ int16_t faceIndex;
|
||||
/* 000E */ int16_t interior;
|
||||
};
|
||||
|
||||
class CMap {
|
||||
public:
|
||||
static TSGrowableArray<CGxVertexPC> debugVertexArray;
|
||||
static TSGrowableArray<uint16_t> debugIndexArray;
|
||||
static CMapLight* s_mapLight;
|
||||
static CMapLowDetail s_lowDetail;
|
||||
static SMMapHeader header;
|
||||
static bool gTerrainPixelShadersValid;
|
||||
static bool enableTerrainShaderVertex;
|
||||
static uint32_t version;
|
||||
static int32_t bPreload;
|
||||
static int32_t s_isStreamingMode;
|
||||
static bool s_unk_CE049C;
|
||||
static bool enableSpecular;
|
||||
static bool enablePixelShaders;
|
||||
static bool enableVertexShaders;
|
||||
static TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > mapObjDefLinkList;
|
||||
static TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > s_unk_AF16CC;
|
||||
static CGxBuf* lowDetailIndexBuf;
|
||||
static CGxPool* lowDetailIndexPool;
|
||||
static CGxShader* pixelShader_TerrainSM;
|
||||
@@ -94,8 +141,8 @@ class CMap {
|
||||
static int32_t uniqueId;
|
||||
static int32_t oldSelectLightParm;
|
||||
static uint32_t s_queryTag;
|
||||
static int32_t cCount;
|
||||
static uint32_t unk[4096];
|
||||
static uint32_t cCount;
|
||||
static CMapAreaMed* unk[4096];
|
||||
static CMapArea* m_areaTable[4096];
|
||||
static SMAreaInfo m_areaInfo[4096];
|
||||
static TSGrowableArray<uint32_t> scCollideList;
|
||||
@@ -124,7 +171,29 @@ class CMap {
|
||||
static FVBBList s_vbbList;
|
||||
static TSExplicitList<CMapRenderChunk, offsetof(CMapRenderChunk, m_renderChunkLink)> s_mapRenderChunkFreeList;
|
||||
static TSExplicitList<CMapChunkBuf, offsetof(CMapChunkBuf, unk_0014)> s_unk_AEED80;
|
||||
static TSList<CMapArea, TSGetExplicitLink<CMapArea> > s_unk_AEED8C;
|
||||
static TSList<CMapChunk, TSGetExplicitLink<CMapChunk> > s_mapChunkList;
|
||||
static TSList<CMapObjDefGroup, TSGetExplicitLink<CMapObjDefGroup> > mapObjDefGroupList;
|
||||
static TSList<CMapEntity, TSGetExplicitLink<CMapEntity> > entityList;
|
||||
static TSList<CMapLight, TSGetExplicitLink<CMapLight> > lightList;
|
||||
static TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > s_unk_ADFBEC;
|
||||
static TSExplicitList<CMapRenderChunk, offsetof(CMapRenderChunk, m_renderChunkLink)> s_mapRenderChunkUpdateList;
|
||||
static bool enableSpecularTerrain;
|
||||
static char wdtFilename[256];
|
||||
static char mapName[256];
|
||||
static char mapPath[256];
|
||||
static C3Vector s_subchunkCoords[5];
|
||||
static uint32_t s_holeMask[16];
|
||||
static int32_t s_subchunkIndices[8];
|
||||
static int32_t s_fanIndices[8];
|
||||
static TSList<CMapDoodadDef, TSGetExplicitLink<CMapDoodadDef> > doodadDefList;
|
||||
static TSHashTable<CMapObjDef, HASHKEY_NONE> mapObjDefHash;
|
||||
static int32_t enableChunkBatching;
|
||||
static TSList<CChunkLiquid, TSGetExplicitLink<CChunkLiquid> > s_chunkLiquidList;
|
||||
static TSList<CChunkLiquid, TSGetExplicitLink<CChunkLiquid> > s_mapChunkLiquidUpdateList;
|
||||
static DepthCoordTable* s_depthCoordTables[2];
|
||||
|
||||
static void ClearAllRenderChunks();
|
||||
static void Destroy();
|
||||
static void FootprintDestroy();
|
||||
static void FootprintInitialize();
|
||||
@@ -134,6 +203,103 @@ class CMap {
|
||||
static void InitializePCFShaders();
|
||||
static void QueryAreaId(CMapEntity* entity, uint32_t& areaId);
|
||||
static void Unload();
|
||||
static void ValidateShaders();
|
||||
static CGxShader* GetPixelShader(bool a1, bool a2, bool a3);
|
||||
static CGxShader* GetTerrainPixelShader(int32_t bigAlpha, int32_t layers, int32_t shadowMode, int32_t a4, int32_t a5);
|
||||
static void Load(const char* mapName, int32_t zoneID);
|
||||
static void LoadTex();
|
||||
static void LoadWdt();
|
||||
static CTexture* LoadTexture(const char* fileName);
|
||||
static int32_t SafeOpen(const char* fileName, SFileImpl** file);
|
||||
static int32_t SafeRead(const char* fileName, SFileImpl* file, void* buffer, uint32_t size);
|
||||
static CMapArea* AllocArea();
|
||||
static CMapAreaLow* AllocAreaLow();
|
||||
static void FreeArea(CMapArea* area);
|
||||
static void FreeAreaMed(CMapAreaMed* areaMed);
|
||||
static void FreeChunk(CMapChunk* chunk);
|
||||
static CMapChunk* AllocMapChunk();
|
||||
static CMapRenderChunk* AllocRenderChunk();
|
||||
static CMapBaseObjLink* AllocBaseObjLink(CMapBaseObj* baseObj);
|
||||
static CMapDoodadDef* AllocDoodadDef();
|
||||
static CMapObjDef* AllocMapObjDef();
|
||||
static CMapObj* AllocMapObj();
|
||||
static CMapEntity* AllocEntity(int32_t linkToHead);
|
||||
static CMapObjGroup* AllocMapObjGroup();
|
||||
static CMapObjDefGroup* AllocMapObjDefGroup();
|
||||
static CMapLight* AllocLight();
|
||||
static CMapObjDef* CreateMapObjDef(char* fileName, SMMapObjDef* mapObjectDef, C3Vector* center, bool cached);
|
||||
static CMapLight* CreateLight(uint8_t a1, uint8_t a2);
|
||||
static CMapDoodadDef* CreateDoodadDef(uint32_t doodadRef, SMODoodadDef* doodadDef, char* name, uint32_t uniqueId, C44Matrix* mat, uint16_t doodadSet);
|
||||
static void FreeBaseObjLink(CMapBaseObjLink* link);
|
||||
static CMapArea* PrepareArea(int32_t areaIndexX, int32_t areaIndexY);
|
||||
static void LoadArea(CMapArea* area);
|
||||
static void PrepareUpdate(bool a1);
|
||||
static void PurgeMaps();
|
||||
static void PurgeUnkCache();
|
||||
static void PreUpdateAreas(bool a1);
|
||||
static void UpdateArea(int32_t addToScene, CMapArea* area, CiRect* chunkRect, int32_t depth);
|
||||
static void PrepareMapObjDefs(bool a1);
|
||||
static void PrepareMapObjDef(CMapObjDef* mapObjDef, CMapObj* mapObj);
|
||||
static void CreateMapObjDefGroups(CMapObj* mapObj, CMapObjDef* mapObjDef);
|
||||
static bool QueryShadow(C3Vector* pos);
|
||||
static DepthCoordTable* GetDepthCoordTable(uint32_t liquidType);
|
||||
static CChunkLiquid* AllocChunkLiquid();
|
||||
static void CreateWaterRipple(const C3Vector& pos, float a2, float a3, float a4, float a5, float a6, int32_t a7, int32_t a8);
|
||||
static bool QueryLiquidSounds(C3Vector* pos, float radius, uint32_t* results);
|
||||
static bool QueryLiquidStatus(C3Vector* pos, int32_t* liquidType, float* height, int32_t* a4, int32_t checkGround);
|
||||
static bool QueryLiquidTerrain(const C3Vector* pos, int32_t* liquidType, float* height, int32_t checkGround);
|
||||
static void RenderWaterRipples();
|
||||
static void FreeChunkLiquid(CChunkLiquid* liquid);
|
||||
static void FreeAllChunkLiquids();
|
||||
static void ProcessChunkLiquidUpdateList();
|
||||
static void PrepareMapDoodadDefs();
|
||||
static void ProcessRenderChunkUpdateList();
|
||||
static CMapEntity* ObjectCreate(CM2Model* model, MAP_OBJECT_FUNC func, void* funcParam, uint64_t param64, uint32_t param32, uint32_t a7);
|
||||
static void ObjectUpdate(CMapEntity* entity, C44Matrix& mat, CAaBox& box, CAaSphere& sphere, C3Vector& vec, bool a6, uint32_t a7);
|
||||
static void PrepareEntitys(int32_t addToScene);
|
||||
static void LinkStaticEntityMultiple2(CMapStaticEntity* entity);
|
||||
static void LinkStaticEntity(CMapStaticEntity* entity, C3Vector& top, C3Vector& bottom, C3Vector& mid, int32_t& outInterior, int32_t& outHit, MapObjIntersectData* interiorHit, MapObjIntersectData* groundHit);
|
||||
static void UpdateEntity(CMapEntity* entity);
|
||||
static void LinkStaticEntityMultiple2ToMapObjDefInterior(CMapStaticEntity* entity, CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup);
|
||||
static void LinkObjectToMapObjDefGroup(CMapStaticEntity* object, CMapObjDefGroup* mapObjDefGroup);
|
||||
static void LinkStaticEntitySingle2(CMapStaticEntity* entity);
|
||||
static void LinkStaticEntity(CMapStaticEntity* entity);
|
||||
static void LinkIntersectMapObjDefGroup(CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup, C3Vector& start, C3Vector& end, MapObjIntersectData* interiorHit, MapObjIntersectData* groundHit);
|
||||
static bool LinkIntersectMapObjDef(CMapObjDef* mapObjDef, C3Vector& start, C3Vector& end, C3Vector& mid, MapObjIntersectData* interiorHit, MapObjIntersectData* groundHit);
|
||||
static bool LinkIntersectMapObjDefs(C3Vector& start, C3Vector& end, C3Vector& mid, MapObjIntersectData* interiorHit, MapObjIntersectData* groundHit, CMapChunk* chunk);
|
||||
static bool GetHeightTerrain(CMapChunk* chunk, C3Vector& pos, int32_t cellX, int32_t cellY, float* outHeight);
|
||||
static bool LinkStaticEntityGetChunk(C3Vector& pos, float* outHeight, CMapChunk** outChunk);
|
||||
static void ClassifyStaticEntityLink(CMapStaticEntity* entity, CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup, uint32_t faceInfo, C3Vector* pos);
|
||||
static bool LinkObjectToMapExterior(CMapStaticEntity* object);
|
||||
static bool QueryGroundTypeTerrain(C3Vector* pos, uint32_t* groundType);
|
||||
static void LinkStaticEntityMultiple2ToMapObjDefExterior(CMapStaticEntity* entity);
|
||||
static void EnableLight(CMapLight* light);
|
||||
static void UpdateLight(CMapLight* light);
|
||||
static void UpdateLightBounds(CMapLight* light);
|
||||
static void LinkLightToMapObjDefs(CMapLight* light);
|
||||
static void LinkLightToChunks(CMapLight* light);
|
||||
static bool Intersect(C3Vector* start, C3Vector* end, C3Vector* hitPoint, float* distance, uint32_t flags, void* hitInfo);
|
||||
static bool VectorIntersect(C3Vector* start, C3Vector* end, uint32_t flags, uint32_t defIgnoreFlags, float* distance, uint16_t* hitIndex, CMapObj** outMapObj, CMapObjDef** outMapObjDef, CMapObjDefGroup** outMapObjDefGroup);
|
||||
static bool VectorIntersectTerrain(C3Vector* start, C3Vector* end, float* distance, uint32_t flags, CMapChunk** hitChunk);
|
||||
static bool VectorIntersectSubChunkList(C3Vector* start, C3Vector* end, float* distance, uint32_t flags, CMapChunk** hitChunk);
|
||||
static void VectorIntersectDoodadDefs(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* list, uint32_t flags);
|
||||
static void VectorIntersectSY(CiRect& rect);
|
||||
static void VectorIntersectSX(CiRect& rect);
|
||||
static void VectorIntersectDY(C3Vector& a1, C3Vector& a2, CiRect& rect);
|
||||
static void VectorIntersectDX(C3Vector& a1, C3Vector& a2, CiRect& rect);
|
||||
static void SetHitTestDebug(void* hitInfo, CMapBaseObj* hitObject);
|
||||
static bool LocateViewerMapObjs(C3Vector& start, C3Vector& end, float dist, CMapObjDef** outDefs, uint32_t* outGroups);
|
||||
static void TestQueryAdd(CFacet& facet, CImVector& color, C44Matrix* mat);
|
||||
static bool GetFacets(CAaBox* a1, CAaBox* a2, World::FacetData* a3, uint32_t a4, uint32_t* a5);
|
||||
static bool GetMapObjFacets(CFrustum* frustum, World::FacetData* facets, uint32_t flags, uint32_t* statusOut);
|
||||
static bool QueryFacets(CFrustum* frustum, World::FacetData* facets, uint32_t flags, uint32_t* a4);
|
||||
static bool GetChunkFacets(int32_t chunkX, int32_t chunkY, CiRect* subRect, CAaBox* a4, CAaBox* box, World::FacetData* facets, uint32_t flags);
|
||||
static CFacet* BuildImpassableFacets(World::FacetData* facets, C3Vector* up, C3Vector* edge, C3Vector* normal, C3Vector* origin);
|
||||
static void CreateImpassableFacets(CMapChunk* chunk, CAaBox* box, World::FacetData* facets);
|
||||
static bool CreateFlightBoundsFacets(int32_t areaX, int32_t areaY, CAaBox* box, World::FacetData* facets);
|
||||
static void AppendMapObjFacets(CMapDoodadDef* def, CAaBox* box, World::FacetData* facets);
|
||||
static bool GetDoodadDefFacets(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* linkList, CAaBox* box, World::FacetData* facets, uint32_t flags);
|
||||
static int32_t GetFlightBounds(const C3Vector& pos, float* height, int32_t which);
|
||||
|
||||
/* 0000 */ uint8_t unk_0000[180];
|
||||
/* 00B4 */ uint32_t unk_00B4;
|
||||
@@ -141,32 +307,4 @@ class CMap {
|
||||
|
||||
extern int32_t s_mapId;
|
||||
|
||||
class CMapAreaLow {
|
||||
public:
|
||||
/* 0000 */ uint8_t unk_0000[1];
|
||||
/* 0001 */ uint8_t unk_0001;
|
||||
/* 0002 */ uint8_t unk_0002;
|
||||
/* 0003 */ uint8_t unk_0003;
|
||||
/* 0004 */ uint8_t unk_0004;
|
||||
/* 0005 */ uint8_t unk_0005;
|
||||
/* 0006 */ uint8_t unk_0006;
|
||||
/* 0007 */ uint8_t unk_0007;
|
||||
/* 0008 */ uint8_t unk_0008;
|
||||
/* 0009 */ uint8_t unk_0009;
|
||||
/* 000A */ uint8_t unk_000A;
|
||||
/* 000B */ uint8_t unk_000B;
|
||||
/* 000C */ uint8_t unk_000C;
|
||||
/* 000D */ uint8_t unk_000D;
|
||||
/* 000E */ uint8_t unk_000E;
|
||||
/* 000F */ uint8_t unk_000F;
|
||||
/* 0010 */ uint8_t unk_0010;
|
||||
/* 0011 */ uint8_t unk_0011;
|
||||
/* 0012 */ uint8_t unk_0012;
|
||||
/* 0013 */ uint8_t unk_0013;
|
||||
/* 0014 */ uint8_t unk_0014;
|
||||
/* 0015 */ uint8_t unk_0015;
|
||||
/* 0016 */ uint8_t unk_0016[4];
|
||||
/* 001A */ uint8_t unk_001A[66];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#include "MapArea.h"
|
||||
#include <cstring>
|
||||
#include "Engine/Source/Services/AsyncFile.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "Engine/Source/Tempest/CiRect.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Services/Texture.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapChunk.h"
|
||||
#include "WoW/Source/WorldClient/MapRenderChunk.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
|
||||
void CMapArea::Destroy() {
|
||||
}
|
||||
@@ -7,3 +20,289 @@ void CMapArea::Destroy() {
|
||||
// OFFSET: 0x005EEB70
|
||||
void CMapArea::Initialize() {
|
||||
}
|
||||
|
||||
// VERIFY: 8d38ed01 manual
|
||||
// OFFSET: 0x007D6810
|
||||
void CMapArea::BatchChunks(const C2iVector& pos) {
|
||||
int32_t index = 16 * pos.y + pos.x;
|
||||
|
||||
CMapChunk* chunks[4];
|
||||
chunks[0] = this->m_mapChunks[index];
|
||||
chunks[1] = this->m_mapChunks[index + 16];
|
||||
chunks[2] = this->m_mapChunks[16 * pos.y + 1 + pos.x];
|
||||
chunks[3] = this->m_mapChunks[16 * pos.y + 17 + pos.x];
|
||||
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
if (!chunks[i]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CMapChunk* topLeft = chunks[0];
|
||||
CMapChunk* bottomLeft = chunks[1];
|
||||
CMapChunk* topRight = chunks[2];
|
||||
CMapChunk* bottomRight = chunks[3];
|
||||
|
||||
int32_t mergeLeft = CMapChunk::CanMergeChunkLayers(bottomLeft, topLeft);
|
||||
int32_t mergeRight = CMapChunk::CanMergeChunkLayers(bottomRight, topRight);
|
||||
int32_t mergeTop = CMapChunk::CanMergeChunkLayers(topRight, topLeft);
|
||||
int32_t mergeBottom = CMapChunk::CanMergeChunkLayers(bottomRight, bottomLeft);
|
||||
|
||||
int32_t vertical = mergeRight + mergeLeft;
|
||||
int32_t horizontal = mergeBottom + mergeTop;
|
||||
|
||||
if (vertical || horizontal) {
|
||||
int32_t firstPartner = 2;
|
||||
int32_t secondStart = 1;
|
||||
int32_t firstMerge = mergeTop;
|
||||
int32_t secondMerge = mergeBottom;
|
||||
uint8_t orientation = 2;
|
||||
|
||||
if (vertical > horizontal) {
|
||||
firstMerge = mergeLeft;
|
||||
firstPartner = 1;
|
||||
secondStart = 2;
|
||||
secondMerge = mergeRight;
|
||||
orientation = 1;
|
||||
}
|
||||
|
||||
if (firstMerge) {
|
||||
CMapRenderChunk* renderChunk = CMap::AllocRenderChunk();
|
||||
CMapChunk* partner = chunks[firstPartner];
|
||||
topLeft->m_renderChunk = renderChunk;
|
||||
renderChunk->AddBatch(topLeft, partner, &topLeft->m_topLeftCoords, orientation);
|
||||
partner->m_renderChunk = topLeft->m_renderChunk;
|
||||
}
|
||||
|
||||
if (secondMerge) {
|
||||
CMapRenderChunk* renderChunk = CMap::AllocRenderChunk();
|
||||
CMapChunk* first = chunks[secondStart];
|
||||
first->m_renderChunk = renderChunk;
|
||||
renderChunk->AddBatch(first, bottomRight, &first->m_topLeftCoords, orientation);
|
||||
bottomRight->m_renderChunk = first->m_renderChunk;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
CMapChunk* chunk = chunks[i];
|
||||
|
||||
if (!chunk->m_renderChunk) {
|
||||
chunk->AllocRenderChunkAndBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: bb694f33 manual
|
||||
// OFFSET: 0x007D6980
|
||||
void CMapArea::LoadTerrainTexture(CMapAreaTexture* areaTexture, int32_t textureId) {
|
||||
bool shaders = g_theGxDevicePtr->Caps().m_texTarget[1] && g_theGxDevicePtr->Caps().m_shaderTargets[0] && g_theGxDevicePtr->Caps().m_shaderTargets[4];
|
||||
|
||||
uint8_t flags = 0;
|
||||
|
||||
if (this->m_textureFlags) {
|
||||
flags = this->m_textureFlags[textureId];
|
||||
}
|
||||
|
||||
if ((flags & 0x1) || !CMap::enableSpecularTerrain) {
|
||||
if (!(flags & 0x1) || shaders) {
|
||||
areaTexture->m_texture = CMap::LoadTexture(areaTexture->m_textureName);
|
||||
} else {
|
||||
CImVector color;
|
||||
color.b = 0x00;
|
||||
color.g = 0x00;
|
||||
color.r = 0x00;
|
||||
color.a = 0xFF;
|
||||
areaTexture->m_texture = TextureCreateSolid(color);
|
||||
}
|
||||
} else {
|
||||
char fileName[256];
|
||||
SStrCopy(fileName, areaTexture->m_textureName, STORM_MAX_STR);
|
||||
char* ext = SStrChrR(fileName, '.');
|
||||
SStrCopy(ext, "_s.blp", STORM_MAX_STR);
|
||||
areaTexture->m_texture = CMap::LoadTexture(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 4696cf2f manual
|
||||
// OFFSET: 0x007D6B30
|
||||
CMapChunk* CMapArea::PrepareChunk(int32_t chunkX, int32_t chunkY) {
|
||||
int32_t index = chunkX + 16 * chunkY;
|
||||
|
||||
bool firstUse = true;
|
||||
|
||||
if (this->m_chunkInfo[index].m_flags & 0x1) {
|
||||
firstUse = false;
|
||||
}
|
||||
|
||||
this->m_chunkInfo[index].m_flags |= 0x1;
|
||||
|
||||
CMapChunk* chunk = CMap::AllocMapChunk();
|
||||
CMapBaseObjLink* link = CMap::AllocBaseObjLink(chunk);
|
||||
link->m_ref = this;
|
||||
this->m_chunkLinkList.LinkToTail(link);
|
||||
|
||||
chunk->m_aIndex.x = chunkX;
|
||||
chunk->m_flags = static_cast<MapObjFlag>(0);
|
||||
chunk->m_aIndex.y = chunkY;
|
||||
chunk->m_cOffset.x = chunkX + this->m_tileChunkIndex.x;
|
||||
chunk->m_cOffset.y = chunkY + this->m_tileChunkIndex.y;
|
||||
chunk->m_sOffset.x = 8 * (chunkX + this->m_tileChunkIndex.x);
|
||||
chunk->m_sOffset.y = 8 * (chunkY + this->m_tileChunkIndex.y);
|
||||
chunk->Create(reinterpret_cast<SIffChunk*>(static_cast<uint8_t*>(this->m_fileBuffer) + this->m_chunkInfo[index].m_offset), firstUse);
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// VERIFY: 0ce80d37 manual
|
||||
// OFFSET: 0x007D6BF0
|
||||
void CMapArea::Update(int32_t addToScene, CiRect* chunkRect) {
|
||||
for (int32_t chunkY = chunkRect->minY; chunkY <= chunkRect->maxY; chunkY++) {
|
||||
int32_t localY = chunkY & 0xF;
|
||||
|
||||
for (int32_t chunkX = chunkRect->minX; chunkX <= chunkRect->maxX; chunkX++) {
|
||||
int32_t localX = chunkX & 0xF;
|
||||
|
||||
if (chunkX >= CWorld::gbChunkRect.minX && chunkX <= CWorld::gbChunkRect.maxX && chunkY >= CWorld::gbChunkRect.minY && chunkY <= CWorld::gbChunkRect.maxY) {
|
||||
CMapChunk** slot = &this->m_mapChunks[localX + 16 * localY];
|
||||
CMapChunk* chunk = *slot;
|
||||
|
||||
if (!chunk) {
|
||||
this->PrepareChunk(localX, localY);
|
||||
chunk = *slot;
|
||||
}
|
||||
|
||||
if (addToScene && CWorldScene::InsideFrustumRect(chunkRect)) {
|
||||
CWorldScene::AddMapChunk(chunk);
|
||||
chunk->CullAndBucketChunk();
|
||||
}
|
||||
} else {
|
||||
CMapChunk* chunk = this->m_mapChunks[16 * localY + localX];
|
||||
|
||||
if (chunk) {
|
||||
this->m_mapChunks[16 * chunk->m_aIndex.y + chunk->m_aIndex.x] = nullptr;
|
||||
CMap::FreeBaseObjLink(chunk->m_parentLinkList.Head());
|
||||
this->PurgeChunk(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 1e0fb652 manual
|
||||
// OFFSET: 0x007D6D20
|
||||
void CMapArea::LoadTextures(char* fileNames, uint32_t fileNamesSize) {
|
||||
uint32_t offset = 0;
|
||||
int32_t streaming = SFile::IsStreamingMode();
|
||||
|
||||
this->m_textures.m_chunk = 16;
|
||||
|
||||
if (!fileNamesSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
CMapAreaTexture* areaTexture = this->m_textures.New();
|
||||
areaTexture->m_textureName = &fileNames[offset];
|
||||
areaTexture->m_texture = nullptr;
|
||||
|
||||
if (!streaming) {
|
||||
this->LoadTerrainTexture(&this->m_textures.m_data[this->m_textures.Count() - 1], this->m_textures.Count() - 1);
|
||||
}
|
||||
|
||||
while (fileNames[offset]) {
|
||||
offset++;
|
||||
}
|
||||
|
||||
offset++;
|
||||
} while (offset < fileNamesSize);
|
||||
}
|
||||
|
||||
// VERIFY: 2e3ea90a manual
|
||||
// OFFSET: 0x007D6EF0
|
||||
void CMapArea::ProcessIffChunks() {
|
||||
SIffChunk* version = static_cast<SIffChunk*>(this->m_fileBuffer);
|
||||
uint8_t* header = reinterpret_cast<uint8_t*>(&version->m_data) + version->m_size + offsetof(SIffChunk, m_data);
|
||||
|
||||
this->m_header = reinterpret_cast<SMAreaHeader*>(header);
|
||||
this->m_chunkInfo = reinterpret_cast<SMChunkInfo*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mcin)->m_data);
|
||||
char* textureNames = reinterpret_cast<char*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mtex)->m_data);
|
||||
this->m_doodadDef = reinterpret_cast<SMDoodadDef*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mddf)->m_data);
|
||||
this->m_mapObjDef = reinterpret_cast<SMMapObjDef*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_modf)->m_data);
|
||||
this->m_m2FileNames = reinterpret_cast<char*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mmdx)->m_data);
|
||||
this->m_wmoFileNames = reinterpret_cast<char*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mwmo)->m_data);
|
||||
this->m_modelFilenamesOffsets = reinterpret_cast<uint32_t*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mmid)->m_data);
|
||||
this->m_wmoFilenamesOffsets = reinterpret_cast<uint32_t*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mwid)->m_data);
|
||||
|
||||
if (this->m_header->m_flags & 0x1) {
|
||||
this->m_flyingBbox = reinterpret_cast<int16_t*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mfbo)->m_data);
|
||||
}
|
||||
|
||||
if (this->m_header->m_mh2o && reinterpret_cast<SIffChunk*>(header + this->m_header->m_mh2o)->m_size) {
|
||||
void* mem = SMemAlloc(sizeof(Liquid::CAreaData), __FILE__, __LINE__, 0);
|
||||
Liquid::CAreaData* liquid = mem ? new (mem) Liquid::CAreaData(nullptr) : nullptr;
|
||||
this->m_liquid = liquid;
|
||||
liquid->SetData(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mh2o)->m_data);
|
||||
}
|
||||
|
||||
if (this->m_header->m_mtxf) {
|
||||
this->m_textureFlags = reinterpret_cast<int32_t*>(&reinterpret_cast<SIffChunk*>(header + this->m_header->m_mtxf)->m_data);
|
||||
}
|
||||
|
||||
this->LoadTextures(textureNames, reinterpret_cast<SIffChunk*>(header + this->m_header->m_mtex)->m_size);
|
||||
|
||||
this->m_doodadDefCount = reinterpret_cast<SIffChunk*>(header + this->m_header->m_mddf)->m_size / sizeof(SMDoodadDef);
|
||||
this->m_mapObjDefCount = reinterpret_cast<SIffChunk*>(header + this->m_header->m_modf)->m_size / sizeof(SMMapObjDef);
|
||||
}
|
||||
|
||||
// VERIFY: ff270d7a auto
|
||||
// OFFSET: 0x007D7020
|
||||
void CMapArea::AsyncCallback(void* param) {
|
||||
CMapArea* area = static_cast<CMapArea*>(param);
|
||||
|
||||
area->ProcessIffChunks();
|
||||
AsyncFileReadDestroyObject(area->m_asyncObject);
|
||||
area->m_asyncObject = nullptr;
|
||||
area->m_file = nullptr;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007D7050
|
||||
CMapArea::CMapArea() {
|
||||
this->m_index.x = 0;
|
||||
this->m_index.y = 0;
|
||||
this->m_tileChunkIndex.x = 0;
|
||||
this->m_tileChunkIndex.y = 0;
|
||||
this->m_chunkLinkList.SetLinkOffset(offsetof(CMapBaseObjLink, m_refLink));
|
||||
this->m_file = nullptr;
|
||||
this->m_asyncObject = nullptr;
|
||||
memset(this->m_mapChunks, 0, sizeof(this->m_mapChunks));
|
||||
this->m_fileBuffer = nullptr;
|
||||
this->m_fileSize = 0;
|
||||
this->unk_008C = 0;
|
||||
this->m_doodadDef = nullptr;
|
||||
this->m_mapObjDef = nullptr;
|
||||
this->m_chunkInfo = nullptr;
|
||||
this->m_doodadDefCount = 0;
|
||||
this->m_mapObjDefCount = 0;
|
||||
this->m_m2FileNames = nullptr;
|
||||
this->m_wmoFileNames = nullptr;
|
||||
this->m_modelFilenamesOffsets = nullptr;
|
||||
this->m_wmoFilenamesOffsets = nullptr;
|
||||
this->m_flyingBbox = nullptr;
|
||||
this->m_textureFlags = nullptr;
|
||||
this->m_liquid = nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 09d8cf56 auto
|
||||
// OFFSET: 0x007D7150
|
||||
void CMapArea::Load(const char* fileName) {
|
||||
CMap::SafeOpen(fileName, &this->m_file);
|
||||
this->m_fileSize = SFileGetFileSize(this->m_file, nullptr);
|
||||
this->m_fileBuffer = CMapArea::AllocAsyncLoadBuffer(this->m_fileSize);
|
||||
this->m_asyncObject = AsyncFileReadAllocObject();
|
||||
this->m_asyncObject->m_file = this->m_file;
|
||||
this->m_asyncObject->m_buffer = this->m_fileBuffer;
|
||||
this->m_asyncObject->m_size = this->m_fileSize;
|
||||
this->m_asyncObject->m_userArg = this;
|
||||
this->m_asyncObject->m_userPostloadCallback = reinterpret_cast<void*>(&CMapArea::AsyncCallback);
|
||||
AsyncFileReadObject(this->m_asyncObject, 0);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,17 @@
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
|
||||
class CiRect;
|
||||
|
||||
class CAsyncObject;
|
||||
class SFileImpl;
|
||||
class CMapArea;
|
||||
class CMapAreaChunkLink;
|
||||
class CMapBaseObjLink;
|
||||
class CMapAreaTexture;
|
||||
class CMapChunk;
|
||||
struct SMAreaHeader;
|
||||
@@ -32,6 +37,8 @@ class CMapArea : public CMapBaseObj {
|
||||
public:
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static void* AllocAsyncLoadBuffer(int32_t fileSize);
|
||||
static void AsyncCallback(void* param);
|
||||
|
||||
/* 0024 */ CAaBox m_bounds;
|
||||
/* 003C */ C3Vector m_topLeft2;
|
||||
@@ -39,9 +46,9 @@ class CMapArea : public CMapBaseObj {
|
||||
/* 0050 */ C2iVector m_tileChunkIndex;
|
||||
/* 0058 */ TSGrowableArray<CMapAreaTexture> m_textures;
|
||||
/* 0068 */ SMAreaHeader* m_header;
|
||||
/* 006C */ int32_t m_file;
|
||||
/* 006C */ SFileImpl* m_file;
|
||||
/* 0070 */ CAsyncObject* m_asyncObject;
|
||||
/* 0074 */ TSExplicitList<CMapAreaChunkLink> m_chunkLinkList;
|
||||
/* 0074 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_chunkLinkList;
|
||||
/* 0080 */ void* m_fileBuffer;
|
||||
/* 0084 */ int32_t m_fileSize;
|
||||
/* 0088 */ SMChunkInfo* m_chunkInfo;
|
||||
@@ -56,8 +63,20 @@ class CMapArea : public CMapBaseObj {
|
||||
/* 00AC */ uint32_t* m_wmoFilenamesOffsets;
|
||||
/* 00B0 */ int16_t* m_flyingBbox;
|
||||
/* 00B4 */ int32_t* m_textureFlags;
|
||||
/* 00B8 */ uint8_t* unk_00B8;
|
||||
/* 00B8 */ Liquid::CAreaData* m_liquid;
|
||||
/* 00BC */ CMapChunk* m_mapChunks [256];
|
||||
|
||||
CMapArea();
|
||||
void Load(const char* fileName);
|
||||
void LoadTextures(char* fileNames, uint32_t fileNamesSize);
|
||||
void LoadTerrainTexture(CMapAreaTexture* areaTexture, int32_t textureId);
|
||||
void ProcessIffChunks();
|
||||
CMapChunk* PrepareChunk(int32_t chunkX, int32_t chunkY);
|
||||
void PurgeChunks(CiRect* chunkRect);
|
||||
void PurgeChunk(CMapChunk* chunk);
|
||||
void Purge();
|
||||
void Update(int32_t addToScene, CiRect* chunkRect);
|
||||
void BatchChunks(const C2iVector& pos);
|
||||
};
|
||||
|
||||
struct SMAreaHeader {
|
||||
@@ -85,9 +104,9 @@ struct SMChunkInfo {
|
||||
/* 000C */ uint8_t unk_000C[4];
|
||||
};
|
||||
|
||||
class CMapAreaMed {
|
||||
class CMapAreaMed : public CMapBaseObj {
|
||||
public:
|
||||
/* 0000 */ uint8_t unk_0000[33404];
|
||||
/* 0024 */ uint8_t unk_0024[33368];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
#include "MapBaseObj.h"
|
||||
|
||||
// VERIFY: ec60c430 manual
|
||||
// OFFSET: 0x007D7260
|
||||
CMapBaseObj::CMapBaseObj() {
|
||||
this->m_type = 1;
|
||||
this->m_refCount = 0;
|
||||
this->m_flags = static_cast<MapObjFlag>(0);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
|
||||
class CM2Lighting;
|
||||
class CMapBaseObj;
|
||||
class CMapBaseObjLink;
|
||||
|
||||
class CMapBaseObj {
|
||||
public:
|
||||
@@ -16,9 +17,13 @@ class CMapBaseObj {
|
||||
/* 000A */ uint16_t m_refCount;
|
||||
/* 000C */ MapObjFlag m_flags;
|
||||
/* 0010 */ TSLink<CMapBaseObj> m_lameAssLink;
|
||||
/* 0018 */ TSExplicitList<CMapBaseObjLink> m_parentLinkList;
|
||||
/* 0018 */ TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_ownerLink)> m_parentLinkList;
|
||||
|
||||
virtual ~CMapBaseObj();
|
||||
virtual void SelectLights(CM2Lighting* lighting);
|
||||
virtual void SelectUnderwater(CM2Lighting* lighting);
|
||||
|
||||
CMapBaseObj();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
#include "MapChunk.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Tempest/CMath.h"
|
||||
#include "WoW/Source/WorldClient/CChunkLiquid.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/DB/Rec/LiquidTypeRec.h"
|
||||
#include "WoW/Source/DB/Rec/LiquidMaterialRec.h"
|
||||
#include "WoW/Source/DB/DBClient/DBClient.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/WorldClient/MapRenderChunk.h"
|
||||
#include <cmath>
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
#include "WoW/Source/WorldClient/MapArea.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CFacet.h"
|
||||
#include "Engine/Source/Tempest/CFrustum.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/MapDoodadDef.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/CWorldMath.h"
|
||||
#include "Engine/Source/Tempest/CiRect.h"
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "Engine/Source/Tempest/C4Plane.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Base/RCString.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
#include "Engine/Source/Gxu/GxuLight.h"
|
||||
|
||||
// STATIC: 0x00D25488
|
||||
float CMapChunk::s_geoToTex;
|
||||
@@ -7,6 +38,84 @@ float CMapChunk::s_geoToTex;
|
||||
// STATIC: 0x00D25498
|
||||
C3Vector CMapChunk::vertexList[145];
|
||||
|
||||
// STATIC: 0x00AEEE3C
|
||||
const int32_t CMapChunk::cornerVertexIndex[4] = { 0, 8, 136, 144 };
|
||||
|
||||
// STATIC: 0x00CD8F38
|
||||
int32_t CMapChunk::farCornerIndex;
|
||||
|
||||
// OFFSET: 0x007C3A10
|
||||
void CMapChunk::ProcessIffChunks(bool a3) {
|
||||
SIffChunk* headerChunk = reinterpret_cast<SIffChunk*>(this->m_chunkInfoBeginPtr);
|
||||
this->m_header = reinterpret_cast<SMChunk*>(&headerChunk->m_data);
|
||||
|
||||
int32_t remaining = headerChunk->m_size - sizeof(SMChunk);
|
||||
SIffChunk* chunk = reinterpret_cast<SIffChunk*>(reinterpret_cast<uint8_t*>(this->m_header) + sizeof(SMChunk));
|
||||
|
||||
while (remaining > 0) {
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(&chunk->m_data);
|
||||
remaining -= offsetof(SIffChunk, m_data);
|
||||
|
||||
switch (chunk->m_token) {
|
||||
case 0x4D434E52:
|
||||
this->m_normals = reinterpret_cast<int8_t*>(data);
|
||||
|
||||
if (a3) {
|
||||
chunk->m_size = 448;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x4D435348:
|
||||
this->m_shadowMap = data;
|
||||
break;
|
||||
|
||||
case 0x4D435654:
|
||||
this->m_height = reinterpret_cast<float*>(data);
|
||||
break;
|
||||
|
||||
case 0x4D435246:
|
||||
this->m_mcrfPtr = data;
|
||||
break;
|
||||
|
||||
case 0x4D435345:
|
||||
if (this->m_header->m_nSndEmitters) {
|
||||
this->m_soundEmitters = reinterpret_cast<CWSoundEmitter*>(data);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x4D434C59:
|
||||
this->m_layers = reinterpret_cast<SMLayer*>(data);
|
||||
break;
|
||||
|
||||
case 0x4D434C51:
|
||||
if (this->m_header->m_sizeLiquid > 8) {
|
||||
this->m_liquid = reinterpret_cast<SMLiquidChunk*>(data);
|
||||
chunk->m_size = this->m_header->m_sizeLiquid - 8;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x4D43414C:
|
||||
this->m_additionalShadowmap = data;
|
||||
|
||||
if (a3) {
|
||||
chunk->m_size = this->m_header->m_sizeAlpha - 8;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x4D434356:
|
||||
this->m_vertexShading = reinterpret_cast<uint32_t*>(data);
|
||||
break;
|
||||
}
|
||||
|
||||
remaining -= chunk->m_size;
|
||||
chunk = reinterpret_cast<SIffChunk*>(data + chunk->m_size);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 86d6cd8c manual
|
||||
// OFFSET: 0x007C3C60
|
||||
void CMapChunk::InitializeVertexGrid() {
|
||||
@@ -44,3 +153,609 @@ void CMapChunk::Initialize() {
|
||||
void CMapChunk::Destroy() {
|
||||
CMapRenderChunk::Destroy();
|
||||
}
|
||||
|
||||
|
||||
// VERIFY: 5994fc04 auto
|
||||
// OFFSET: 0x007C3B40
|
||||
void CMapChunk::AllocRenderChunkAndBatch() {
|
||||
this->m_renderChunk = CMap::AllocRenderChunk();
|
||||
this->m_renderChunk->AddBatch(this, nullptr, &this->m_topLeftCoords, 0);
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C3B60
|
||||
int16_t CMapChunk::CreateIndices(char* buf, int32_t baseVertex) {
|
||||
uint16_t* indexDst = reinterpret_cast<uint16_t*>(buf);
|
||||
int16_t totalIndices = 0;
|
||||
|
||||
for (int row = 0; row < 8; ++row) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
// Holes are stored as a 4×4 bitmask (one bit per 2×2 block of cells).
|
||||
int holeMaskIndex = (row / 2) * 4 + (col / 2);
|
||||
if (this->m_header->m_holes & CMap::s_holeMask[holeMaskIndex])
|
||||
continue;
|
||||
|
||||
// The five vertices that define this cell.
|
||||
// Each outer row has 9 verts, each inner row has 8 — so 17 per row-pair.
|
||||
uint16_t TL = baseVertex + col;
|
||||
uint16_t TR = baseVertex + col + 1;
|
||||
uint16_t C = baseVertex + col + 9; // inner vertex, midpoint of cell
|
||||
uint16_t BL = baseVertex + col + 17; // next outer row
|
||||
uint16_t BR = baseVertex + col + 18;
|
||||
|
||||
// Four triangles, all fanning from the center point (CCW winding).
|
||||
indexDst[0] = C;
|
||||
indexDst[1] = TL;
|
||||
indexDst[2] = BL; // left
|
||||
indexDst[3] = C;
|
||||
indexDst[4] = TR;
|
||||
indexDst[5] = TL; // top
|
||||
indexDst[6] = C;
|
||||
indexDst[7] = BR;
|
||||
indexDst[8] = TR; // right
|
||||
indexDst[9] = C;
|
||||
indexDst[10] = BL;
|
||||
indexDst[11] = BR; // bottom
|
||||
indexDst += 12;
|
||||
totalIndices += 12;
|
||||
}
|
||||
|
||||
// Advance past this row-pair (9 outer + 8 inner vertices).
|
||||
baseVertex += 17;
|
||||
}
|
||||
|
||||
return totalIndices;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C4960
|
||||
void CMapChunk::CreateVerticesLocal(CGxVertexPN* v) {
|
||||
// ~1/127: scales packed signed-byte normals into [-1, 1] float range
|
||||
static const float NORMAL_SCALE = 0.0078740157f;
|
||||
|
||||
// Both expressions simplify to: 33.333332f * 0.125f = ~4.1667 units/step
|
||||
const float stepX = (17066.666f - (float)this->m_cOffset.x * 33.333332f - (17066.666f - (float)(this->m_cOffset.x + 1) * 33.333332f)) * -0.125f;
|
||||
const float stepY = (17066.666f - (float)this->m_cOffset.y * 33.333332f - (17066.666f - (float)(this->m_cOffset.y + 1) * 33.333332f)) * -0.125f;
|
||||
|
||||
const float halfStepX = stepX * 0.5f;
|
||||
|
||||
float* height = this->m_height;
|
||||
int8_t* normals = this->m_normals;
|
||||
|
||||
for (int row = 0; row < 9; row++) {
|
||||
// --- Outer grid row: 9 evenly-spaced vertices ---
|
||||
const float outerX = (float)row * stepY;
|
||||
|
||||
for (int col = 0; col < 9; col++) {
|
||||
v->m_position.x = outerX;
|
||||
v->m_position.y = (float)col * stepX;
|
||||
v->m_position.z = height[col];
|
||||
v->m_normal.x = normals[col * 3 + 0] * NORMAL_SCALE;
|
||||
v->m_normal.y = normals[col * 3 + 1] * NORMAL_SCALE;
|
||||
v->m_normal.z = normals[col * 3 + 2] * NORMAL_SCALE;
|
||||
v++;
|
||||
}
|
||||
|
||||
height += 9;
|
||||
normals += 27; // 9 vertices * 3 components
|
||||
|
||||
// --- Inner (center-point) grid row: 8 vertices, staggered by half a step ---
|
||||
// The last outer row (row == 8) has no corresponding inner row
|
||||
if (row < 8) {
|
||||
const float innerX = (float)row * stepX + 0.5f * stepY;
|
||||
|
||||
for (int col = 0; col < 8; col++) {
|
||||
v->m_position.x = innerX;
|
||||
v->m_position.y = (float)col * stepY + halfStepX;
|
||||
v->m_position.z = height[col];
|
||||
v->m_normal.x = normals[col * 3 + 0] * NORMAL_SCALE;
|
||||
v->m_normal.y = normals[col * 3 + 1] * NORMAL_SCALE;
|
||||
v->m_normal.z = normals[col * 3 + 2] * NORMAL_SCALE;
|
||||
v++;
|
||||
}
|
||||
|
||||
height += 8;
|
||||
normals += 24; // 8 vertices * 3 components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// OFFSET: 0x007C4F10
|
||||
void CMapChunk::CreateVerticesLocal(CGxVertexPNC* v) {
|
||||
float stepX = (17066.666f - this->m_cOffset.x * 33.333332f - (17066.666f - (this->m_cOffset.x + 1) * 33.333332f)) * -0.125f;
|
||||
float stepY = -0.125f * (17066.666f - this->m_cOffset.y * 33.333332f - (17066.666f - 33.333332f * (this->m_cOffset.y + 1)));
|
||||
float halfStepX = stepX * 0.5f;
|
||||
float halfStepY = 0.5f * stepY;
|
||||
|
||||
float* height = this->m_height;
|
||||
int8_t* normals = this->m_normals;
|
||||
uint32_t* shading = this->m_vertexShading;
|
||||
|
||||
for (int32_t row = 0; row < 9; row++) {
|
||||
for (int32_t col = 0; col < 9; col++) {
|
||||
v->m_position.x = stepY * row;
|
||||
v->m_position.y = col * stepX;
|
||||
v->m_position.z = *height;
|
||||
v->m_normal.x = normals[0] * 0.0078740157f;
|
||||
v->m_normal.y = normals[1] * 0.0078740157f;
|
||||
v->m_normal.z = normals[2] * 0.0078740157f;
|
||||
|
||||
if (this->m_vertexShading) {
|
||||
CImVector color = *reinterpret_cast<CImVector*>(shading);
|
||||
|
||||
if (g_theGxDevicePtr->Caps().m_colorFormat == GxCF_rgba) {
|
||||
CImVector swapped;
|
||||
swapped.b = color.r;
|
||||
swapped.g = color.g;
|
||||
swapped.r = color.b;
|
||||
swapped.a = color.a;
|
||||
v->m_color = swapped;
|
||||
} else {
|
||||
v->m_color = color;
|
||||
}
|
||||
} else {
|
||||
*reinterpret_cast<uint32_t*>(&v->m_color) = 0xFF7F7F7F;
|
||||
}
|
||||
|
||||
height++;
|
||||
v++;
|
||||
normals += 3;
|
||||
shading++;
|
||||
}
|
||||
|
||||
if (row < 8) {
|
||||
float innerX = row * stepX + halfStepY;
|
||||
|
||||
for (int32_t col = 0; col < 8; col++) {
|
||||
v->m_position.x = innerX;
|
||||
v->m_position.y = col * stepY + halfStepX;
|
||||
v->m_position.z = *height;
|
||||
v->m_normal.x = normals[0] * 0.0078740157f;
|
||||
v->m_normal.y = normals[1] * 0.0078740157f;
|
||||
v->m_normal.z = normals[2] * 0.0078740157f;
|
||||
|
||||
if (this->m_vertexShading) {
|
||||
CImVector color = *reinterpret_cast<CImVector*>(shading);
|
||||
|
||||
if (g_theGxDevicePtr->Caps().m_colorFormat == GxCF_rgba) {
|
||||
CImVector swapped;
|
||||
swapped.b = color.r;
|
||||
swapped.g = color.g;
|
||||
swapped.r = color.b;
|
||||
swapped.a = color.a;
|
||||
v->m_color = swapped;
|
||||
} else {
|
||||
v->m_color = color;
|
||||
}
|
||||
} else {
|
||||
*reinterpret_cast<uint32_t*>(&v->m_color) = 0xFF7F7F7F;
|
||||
}
|
||||
|
||||
height++;
|
||||
v++;
|
||||
normals += 3;
|
||||
shading++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C51B0
|
||||
void CMapChunk::CreateIndices(uint16_t* buf, CGxBatch* batch) {
|
||||
int32_t baseVertex = batch->m_maxIndex ? batch->m_maxIndex + 1 : 0;
|
||||
int16_t count = this->CreateIndices(reinterpret_cast<char*>(buf), baseVertex);
|
||||
|
||||
uint16_t minIndex = batch->m_minIndex;
|
||||
|
||||
if (minIndex >= baseVertex) {
|
||||
minIndex = baseVertex;
|
||||
}
|
||||
|
||||
batch->m_minIndex = minIndex;
|
||||
|
||||
int32_t maxIndex = CMapRenderChunk::unk_AEEC60.m_maxIndex + baseVertex;
|
||||
|
||||
if (batch->m_maxIndex > maxIndex) {
|
||||
maxIndex = batch->m_maxIndex;
|
||||
}
|
||||
|
||||
batch->m_maxIndex = maxIndex;
|
||||
batch->m_count += count;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C5220
|
||||
void CMapChunk::CreateBounds() {
|
||||
int32_t tileX = this->m_cOffset.x;
|
||||
int32_t tileY = this->m_cOffset.y;
|
||||
|
||||
this->m_bbox.b.x = 17066.666f - 33.333332f * (tileY + 1);
|
||||
this->m_bbox.t.x = 17066.666f - 33.333332f * tileY;
|
||||
this->m_bbox.b.y = 17066.666f - 33.333332f * (tileX + 1);
|
||||
this->m_bbox.t.y = 17066.666f - 33.333332f * tileX;
|
||||
this->m_bbox.b.z = 3.4028235e38f;
|
||||
this->m_bbox.t.z = -3.4028235e38f;
|
||||
|
||||
float* h = this->m_height;
|
||||
int count = 29;
|
||||
do {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
float height = h[i];
|
||||
if (this->m_bbox.b.z > height)
|
||||
this->m_bbox.b.z = height;
|
||||
if (this->m_bbox.t.z < height)
|
||||
this->m_bbox.t.z = height;
|
||||
}
|
||||
h += 5;
|
||||
} while (--count);
|
||||
|
||||
this->m_bbox.b.z += this->m_topLeftCoords.z;
|
||||
this->m_bbox.t.z += this->m_topLeftCoords.z;
|
||||
|
||||
this->m_sphere.c.x = (this->m_bbox.b.x + this->m_bbox.t.x) * 0.5f;
|
||||
this->m_sphere.c.y = (this->m_bbox.b.y + this->m_bbox.t.y) * 0.5f;
|
||||
this->m_sphere.c.z = (this->m_bbox.b.z + this->m_bbox.t.z) * 0.5f;
|
||||
|
||||
this->m_bbox2 = this->m_bbox;
|
||||
|
||||
float ex = this->m_bbox.t.x - this->m_sphere.c.x;
|
||||
float ey = this->m_bbox.t.y - this->m_sphere.c.y;
|
||||
float ez = this->m_bbox.t.z - this->m_sphere.c.z;
|
||||
this->m_sphere.r = sqrt(ex * ex + ey * ey + ez * ez);
|
||||
}
|
||||
|
||||
// VERIFY: baa581e9 auto
|
||||
// OFFSET: 0x007C5440
|
||||
void CMapChunk::Batch() {
|
||||
if (this->m_bLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CMap::enableChunkBatching) {
|
||||
CMapArea* area = static_cast<CMapArea*>(this->m_parentLinkList.Head()->m_ref);
|
||||
|
||||
C2iVector pos;
|
||||
pos.x = this->m_aIndex.x & ~1;
|
||||
pos.y = this->m_aIndex.y & ~1;
|
||||
area->BatchChunks(pos);
|
||||
} else {
|
||||
this->m_renderChunk = CMap::AllocRenderChunk();
|
||||
this->m_renderChunk->AddBatch(this, nullptr, &this->m_topLeftCoords, 0);
|
||||
this->m_bLoaded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2c8f1c5e auto
|
||||
// OFFSET: 0x007C54C0
|
||||
void CMapChunk::CreateVertices(char* buf, int32_t vertexOffset, const C3Vector& offset) {
|
||||
if (CMap::enableTerrainShaderVertex) {
|
||||
if (CMapRenderChunk::s_gxBufVertexFormat == GxVBF_PN) {
|
||||
this->CreateVerticesWorld(reinterpret_cast<CGxVertexPN*>(buf) + vertexOffset, offset);
|
||||
} else {
|
||||
this->CreateVerticesWorld(reinterpret_cast<CGxVertexPNC*>(buf) + vertexOffset, offset);
|
||||
}
|
||||
} else if (CMapRenderChunk::s_gxBufVertexFormat == GxVBF_PN) {
|
||||
this->CreateVerticesLocal(reinterpret_cast<CGxVertexPN*>(buf));
|
||||
} else {
|
||||
this->CreateVerticesLocal(reinterpret_cast<CGxVertexPNC*>(buf));
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 4f0133d9 auto
|
||||
// OFFSET: 0x007C5530
|
||||
void CMapChunk::GetLiquidBounds(CAaBox& box) const {
|
||||
box.t = this->m_bbox.t;
|
||||
box.b = this->m_bbox.b;
|
||||
|
||||
CChunkLiquid* liquid = const_cast<CMapChunk*>(this)->m_liquidChunkLinkList.Head();
|
||||
|
||||
if (liquid) {
|
||||
box.t.z = liquid->m_height.y;
|
||||
box.b.z = liquid->m_height.x;
|
||||
|
||||
do {
|
||||
box.t.z = liquid->m_height.y >= box.t.z ? liquid->m_height.y : box.t.z;
|
||||
box.b.z = liquid->m_height.x <= box.b.z ? liquid->m_height.x : box.b.z;
|
||||
liquid = const_cast<CMapChunk*>(this)->m_liquidChunkLinkList.Next(liquid);
|
||||
} while (liquid);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 16a231ad manual
|
||||
// OFFSET: 0x007C55D0
|
||||
bool CMapChunk::GetLiquidHeight(const C2Vector& pos, float* height) const {
|
||||
int32_t x = CMath::fint_(pos.x - 0.5f);
|
||||
int32_t y = CMath::fint_(pos.y - 0.5f);
|
||||
|
||||
C2iVector tile;
|
||||
tile.x = x & 7;
|
||||
tile.y = y & 7;
|
||||
|
||||
C2Vector frac(pos.x - x, pos.y - y);
|
||||
|
||||
for (CChunkLiquid* liquid = const_cast<CMapChunk*>(this)->m_liquidChunkLinkList.Head(); liquid; liquid = const_cast<CMapChunk*>(this)->m_liquidChunkLinkList.Next(liquid)) {
|
||||
if (liquid->TileExists(tile.x, tile.y) && liquid->GetHeight(frac, tile, *height)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// VERIFY: 981b86cf manual
|
||||
// OFFSET: 0x007C5690
|
||||
void CMapChunk::CreateLiquids(bool a3) {
|
||||
CChunkLiquid* liquid = this->m_liquidChunkLinkList.Head();
|
||||
|
||||
while (liquid) {
|
||||
liquid->m_chunkLink.Unlink();
|
||||
liquid->Purge();
|
||||
CMap::FreeChunkLiquid(liquid);
|
||||
liquid = this->m_liquidChunkLinkList.Next(liquid);
|
||||
}
|
||||
|
||||
SMLiquidChunk* mclq = this->m_liquid;
|
||||
|
||||
if (mclq) {
|
||||
uint32_t flag = 4;
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (flag & this->m_header->m_flags) {
|
||||
uint32_t type = i + 1;
|
||||
|
||||
if (s_mapId == 530 && i == 2) {
|
||||
type = 15;
|
||||
}
|
||||
|
||||
LiquidTypeRec* typeRec = g_liquidTypeDB.GetRecord(type);
|
||||
LiquidMaterialRec* materialRec = g_liquidMaterialDB.GetRecord(typeRec->m_materialID);
|
||||
|
||||
CChunkLiquid* chunkLiquid = CMap::AllocChunkLiquid();
|
||||
this->m_liquidChunkLinkList.LinkToTail(chunkLiquid);
|
||||
chunkLiquid->m_type = type;
|
||||
chunkLiquid->m_owner = this;
|
||||
chunkLiquid->unk_0008 = materialRec->m_lvf;
|
||||
chunkLiquid->m_topLeftCoords = this->m_topLeftCoords;
|
||||
chunkLiquid->m_height = *reinterpret_cast<C2Vector*>(&mclq->m_minHeight);
|
||||
|
||||
uint8_t* verts = reinterpret_cast<uint8_t*>(mclq->m_verts);
|
||||
chunkLiquid->m_tileBegin.x = 0;
|
||||
chunkLiquid->m_tileBegin.y = 0;
|
||||
chunkLiquid->m_tileEnd.x = 8;
|
||||
chunkLiquid->m_tileEnd.y = 8;
|
||||
|
||||
void* mem = SMemAlloc(sizeof(Liquid::CChunkVertexData), __FILE__, __LINE__, 0);
|
||||
Liquid::CChunkVertexData* vertexData = mem ? new (mem) Liquid::CChunkVertexData(verts, chunkLiquid->unk_0008) : nullptr;
|
||||
chunkLiquid->m_tiles = reinterpret_cast<uint8_t*>(&mclq->m_tiles);
|
||||
chunkLiquid->m_vertexData = vertexData;
|
||||
mclq++;
|
||||
|
||||
chunkLiquid->CreateVertXY();
|
||||
}
|
||||
|
||||
flag *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
CMapArea* area = static_cast<CMapArea*>(this->m_parentLinkList.Head()->m_ref);
|
||||
|
||||
if (area->m_liquid && area->m_liquid->HasData()) {
|
||||
const SMLiquidChunkDesc* chunkDesc = area->m_liquid->GetChunkDesc(this->m_aIndex.x, this->m_aIndex.y);
|
||||
this->m_deepBits.SetRawData(const_cast<char*>(reinterpret_cast<const char*>(area->m_liquid->GetDeepTable(chunkDesc))), 64, false);
|
||||
this->m_fishableBits.SetRawData(const_cast<char*>(reinterpret_cast<const char*>(area->m_liquid->GetFishableTable(chunkDesc))), 64, false);
|
||||
|
||||
for (uint32_t i = 0; i < chunkDesc->m_layerCount; i++) {
|
||||
const SMLiquidInstance* instance = area->m_liquid->GetInstanceDesc(chunkDesc, i);
|
||||
|
||||
CChunkLiquid* chunkLiquid = CMap::AllocChunkLiquid();
|
||||
this->m_liquidChunkLinkList.LinkToTail(chunkLiquid);
|
||||
chunkLiquid->m_owner = this;
|
||||
chunkLiquid->m_type = instance->m_liquidType;
|
||||
chunkLiquid->unk_0008 = instance->m_vertexFormat;
|
||||
chunkLiquid->m_topLeftCoords = this->m_topLeftCoords;
|
||||
chunkLiquid->m_height = *reinterpret_cast<const C2Vector*>(&instance->m_minHeight);
|
||||
|
||||
uint8_t yOffset = instance->m_yOffset;
|
||||
uint8_t xOffset = instance->m_xOffset;
|
||||
chunkLiquid->m_tileBegin.x = yOffset;
|
||||
chunkLiquid->m_tileBegin.y = xOffset;
|
||||
chunkLiquid->m_tileEnd.x = yOffset + instance->m_height;
|
||||
chunkLiquid->m_tileEnd.y = xOffset + instance->m_width;
|
||||
|
||||
void* mem = SMemAlloc(sizeof(Liquid::CInstanceVertexData), __FILE__, __LINE__, 0);
|
||||
chunkLiquid->m_vertexData = mem ? new (mem) Liquid::CInstanceVertexData(area->m_liquid, instance) : nullptr;
|
||||
|
||||
uint32_t tileCount = instance->m_width * instance->m_height;
|
||||
chunkLiquid->m_tileBits.SetRawData(const_cast<char*>(reinterpret_cast<const char*>(area->m_liquid->GetExistsTable(instance))), tileCount, false);
|
||||
chunkLiquid->CreateVertXY();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->m_liquidChunkLinkList.Head()) {
|
||||
this->m_liquidBounds.b = C3Vector(3.4028235e38f, 3.4028235e38f, 3.4028235e38f);
|
||||
this->m_liquidBounds.t = C3Vector(-3.4028235e38f, -3.4028235e38f, -3.4028235e38f);
|
||||
} else {
|
||||
this->GetLiquidBounds(this->m_liquidBounds);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2c9fa8ff manual
|
||||
// OFFSET: 0x007C5B20
|
||||
void CMapChunk::CullAndBucketChunk() {
|
||||
if (this->m_liquidBounds.t.x < this->m_liquidBounds.b.x || CWorldScene::FrustumCull(&this->m_liquidBounds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t index = CMapChunk::cornerVertexIndex[CMapChunk::farCornerIndex];
|
||||
float camZ = CWorldScene::s_activeWorldView.z;
|
||||
C3Vector corner(CMapChunk::vertexList[index].x + this->m_topLeftCoords.x, CMapChunk::vertexList[index].y + this->m_topLeftCoords.y, this->m_height[index] + this->m_topLeftCoords.z);
|
||||
|
||||
for (CChunkLiquid* liquid = this->m_liquidChunkLinkList.Head(); liquid; liquid = this->m_liquidChunkLinkList.Next(liquid)) {
|
||||
CAaBox box;
|
||||
liquid->GetAaBox(box);
|
||||
|
||||
if (!CWorldScene::FrustumCull(&box)) {
|
||||
corner.z = (camZ <= liquid->m_height.y ? camZ : liquid->m_height.y) < liquid->m_height.x ? liquid->m_height.x : (camZ > liquid->m_height.y ? liquid->m_height.y : camZ);
|
||||
CWorldScene::AddToDistanceBucket(liquid, corner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C5C50
|
||||
CMapChunk::CMapChunk() {
|
||||
this->m_aIndex.x = 0;
|
||||
this->m_aIndex.y = 0;
|
||||
this->m_sOffset.x = 0;
|
||||
this->m_sOffset.y = 0;
|
||||
this->m_cOffset.x = 0;
|
||||
this->m_cOffset.y = 0;
|
||||
this->m_sphere.r = 0.0f;
|
||||
this->m_sphere.c = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->unk_00B4 = 0;
|
||||
this->unk_00B8 = 0;
|
||||
this->m_sortListLink.m_prevLink = nullptr;
|
||||
this->m_sortListLink.m_next = nullptr;
|
||||
this->m_doodadDefLinkList.SetLinkOffset(offsetof(CMapBaseObjLink, m_refLink));
|
||||
this->m_mapObjDefLinkList.SetLinkOffset(offsetof(CMapBaseObjLink, m_refLink));
|
||||
this->m_entityLinkList.SetLinkOffset(offsetof(CMapBaseObjLink, m_refLink));
|
||||
this->m_lightLinkList.SetLinkOffset(offsetof(CMapBaseObjLink, m_refLink));
|
||||
this->m_soundHandleList.SetLinkOffset(0);
|
||||
this->m_type |= 4;
|
||||
this->m_distToCamera = 0.0f;
|
||||
this->m_flags = static_cast<MapObjFlag>(this->m_flags | MAPOBJ_FLAG_UNPLACED);
|
||||
this->m_detailDoodadInst = nullptr;
|
||||
this->m_renderChunk = nullptr;
|
||||
this->m_chunkInfoBeginPtr = nullptr;
|
||||
this->m_header = nullptr;
|
||||
this->m_lowQualityTexMap = nullptr;
|
||||
this->m_predTexture = nullptr;
|
||||
this->m_height = nullptr;
|
||||
this->m_vertexShading = nullptr;
|
||||
this->m_normals = nullptr;
|
||||
this->m_shadowMap = nullptr;
|
||||
this->m_layers = nullptr;
|
||||
this->m_additionalShadowmap = nullptr;
|
||||
this->m_mcrfPtr = nullptr;
|
||||
this->m_liquid = nullptr;
|
||||
this->m_soundEmitters = nullptr;
|
||||
this->m_bLoaded = 0;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007C64B0
|
||||
void CMapChunk::Create(SIffChunk* headerChunk, bool a3) {
|
||||
this->m_chunkInfoBeginPtr = reinterpret_cast<uint8_t*>(headerChunk);
|
||||
this->ProcessIffChunks(a3);
|
||||
|
||||
this->m_areaId = this->m_header->m_areaid;
|
||||
this->m_topLeftCoords.x = 17066.666f - this->m_cOffset.y * 33.333332f;
|
||||
this->m_topLeftCoords.y = 17066.666f - this->m_cOffset.x * 33.333332f;
|
||||
this->m_topLeftCoords.z = 0.0f;
|
||||
this->m_topLeftCoords.z = this->m_header->m_position.z;
|
||||
this->m_lowQualityTexMap = this->m_header->m_lowQualityTextureMap;
|
||||
this->m_predTexture = reinterpret_cast<uint8_t*>(&this->m_header->m_predTex);
|
||||
|
||||
this->CreateBounds();
|
||||
this->CreateLiquids(a3);
|
||||
this->CreateSoundEmitters(a3);
|
||||
|
||||
this->m_flags = static_cast<MapObjFlag>(0);
|
||||
|
||||
if (this->m_header->m_flags & 2) {
|
||||
this->m_flags = MAPOBJ_FLAG_IMPASSABLE;
|
||||
}
|
||||
|
||||
CMapArea* area = static_cast<CMapArea*>(this->m_parentLinkList.Head()->m_ref);
|
||||
this->CreateRefs(area, reinterpret_cast<uint32_t*>(this->m_mcrfPtr), this->m_header->m_nDoodadRefs, this->m_header->m_nMapObjRefs);
|
||||
area->m_mapChunks[16 * this->m_aIndex.y + this->m_aIndex.x] = this;
|
||||
this->m_flags = static_cast<MapObjFlag>(this->m_flags | MAPOBJ_FLAG_PREPARED);
|
||||
}
|
||||
|
||||
// VERIFY: 1d9777de manual
|
||||
// OFFSET: 0x007C65A0
|
||||
void CMapChunk::UpdateLights() {
|
||||
for (CMapBaseObjLink* link = this->m_doodadDefLinkList.Head(); link; link = this->m_doodadDefLinkList.Next(link)) {
|
||||
link->m_owner->m_flags = static_cast<MapObjFlag>(link->m_owner->m_flags | 0x1);
|
||||
}
|
||||
|
||||
for (CMapBaseObjLink* link = this->m_entityLinkList.Head(); link; link = this->m_entityLinkList.Next(link)) {
|
||||
link->m_owner->m_flags = static_cast<MapObjFlag>(link->m_owner->m_flags | 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 967e03e0 auto
|
||||
// OFFSET: 0x007D3FE0
|
||||
void CMapChunk::RenderPrep() {
|
||||
if (this->m_renderChunk || (this->Batch(), this->m_renderChunk)) {
|
||||
float dy = CWorldScene::s_activeWorldView.y - this->m_sphere.c.y;
|
||||
float dz = CWorldScene::s_activeWorldView.z - this->m_sphere.c.z;
|
||||
float dx = CWorldScene::s_activeWorldView.x - this->m_sphere.c.x;
|
||||
|
||||
if (CWorld::shadowMipLevel || dx * dx + dz * dz + dy * dy > 603729.0f) {
|
||||
this->m_renderChunk->unk_000A |= 0x10;
|
||||
}
|
||||
|
||||
this->m_renderChunk->RenderPrep();
|
||||
}
|
||||
|
||||
if ((CWorld::enables & Enable_DetailDoodads) && CWorld::detailDoodadDist > this->m_distToCamera) {
|
||||
if (!this->m_detailDoodadInst) {
|
||||
this->CreateDetailDoodads();
|
||||
}
|
||||
|
||||
if (this->m_detailDoodadInst) {
|
||||
CWorldScene::AddChunkToSortList(static_cast<CDetailDoodadInst*>(this->m_detailDoodadInst));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x007D66D0
|
||||
bool CMapChunk::CanMergeChunkLayers(CMapChunk* chunkA, CMapChunk* chunkB) {
|
||||
chunkB->m_bLoaded = 1;
|
||||
chunkA->m_bLoaded = 1;
|
||||
|
||||
if (CMap::header.m_flags & 4) {
|
||||
uint32_t count = chunkB->m_header->m_nLayers;
|
||||
SMLayer* layerA = chunkA->m_layers;
|
||||
|
||||
for (uint32_t i = 0; i < chunkA->m_header->m_nLayers; i++, layerA++) {
|
||||
if (layerA->m_flags & 0x4C0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SMLayer* layerB = chunkB->m_layers;
|
||||
bool found = false;
|
||||
|
||||
for (uint32_t j = 0; j < chunkB->m_header->m_nLayers; j++, layerB++) {
|
||||
if (layerB->m_flags & 0x4C0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layerB->m_textureId == layerA->m_textureId) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count <= 4;
|
||||
}
|
||||
|
||||
uint32_t layerCount = chunkA->m_header->m_nLayers;
|
||||
|
||||
if (chunkB->m_header->m_nLayers != layerCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < layerCount; i++) {
|
||||
SMLayer& layerA = chunkA->m_layers[i];
|
||||
SMLayer& layerB = chunkB->m_layers[i];
|
||||
|
||||
if ((layerA.m_flags & 0xC0) || (layerB.m_flags & 0xC0) || layerB.m_textureId != layerA.m_textureId) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Tempest/C2Vector.h"
|
||||
#include "WoW/Source/WorldClient/CChunkLiquid.h"
|
||||
#include "Engine/Source/Base/BitArray.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
@@ -10,6 +13,13 @@
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
|
||||
class CFrustum;
|
||||
class CMapArea;
|
||||
class CiRect;
|
||||
namespace World { class FacetData; }
|
||||
struct SIffChunk;
|
||||
|
||||
class CChunkLiquid;
|
||||
class CMapChunk;
|
||||
@@ -18,6 +28,7 @@ class CMapChunkMapObjDefLink;
|
||||
class CMapObjDef;
|
||||
class CMapRenderChunk;
|
||||
class CWSoundEmitter;
|
||||
class SI2SoundHandle;
|
||||
struct SMChunk;
|
||||
struct SMLayer;
|
||||
struct SMLiquidChunk;
|
||||
@@ -48,18 +59,20 @@ class CMapChunk : public CMapBaseObj {
|
||||
public:
|
||||
static float s_geoToTex;
|
||||
static C3Vector vertexList[145];
|
||||
static int32_t farCornerIndex;
|
||||
static const int32_t cornerVertexIndex[4];
|
||||
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static void InitializeVertexGrid();
|
||||
static bool CanMergeChunkLayers(CMapChunk* chunkA, CMapChunk* chunkB);
|
||||
|
||||
/* 0024 */ C2iVector m_aIndex;
|
||||
/* 002C */ C2iVector m_sOffset;
|
||||
/* 0034 */ C2iVector m_cOffset;
|
||||
/* 003C */ CAaSphere m_sphere;
|
||||
/* 004C */ CAaBox m_bbox;
|
||||
/* 0064 */ C3Vector m_bottomRight;
|
||||
/* 0070 */ C3Vector m_topLeft;
|
||||
/* 0064 */ CAaBox m_liquidBounds;
|
||||
/* 007C */ C3Vector m_topLeftCoords;
|
||||
/* 0088 */ float m_distToCamera;
|
||||
/* 008C */ CAaBox m_bbox2;
|
||||
@@ -70,18 +83,12 @@ class CMapChunk : public CMapBaseObj {
|
||||
/* 00B4 */ int32_t unk_00B4;
|
||||
/* 00B8 */ int32_t unk_00B8;
|
||||
/* 00BC */ TSLink<CMapChunk> m_sortListLink;
|
||||
/* 00C4 */ TSExplicitList<CMapChunkDoodadDefLink> m_doodadDefLinkList;
|
||||
/* 00D0 */ TSExplicitList<CMapChunkMapObjDefLink> m_mapObjDefLinkList;
|
||||
/* 00DC */ int32_t m_tSExplicitListMLinkoffsetDc;
|
||||
/* 00E0 */ void* m_tSExplicitListPtrE0;
|
||||
/* 00E4 */ void* m_tSExplicitListPtr2E4;
|
||||
/* 00E8 */ int32_t m_tSExplicitListMLinkoffsetE8;
|
||||
/* 00EC */ void* m_tSExplicitListPtrEc;
|
||||
/* 00F0 */ void* m_tSExplicitListPtr2F0;
|
||||
/* 00F4 */ int32_t m_tSExplicitListMLinkoffsetF4;
|
||||
/* 00F8 */ void* m_tSExplicitListPtrF8;
|
||||
/* 00FC */ void* m_tSExplicitListPtr2Fc;
|
||||
/* 0100 */ TSExplicitList<CChunkLiquid> m_liquidChunkLinkList;
|
||||
/* 00C4 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_doodadDefLinkList;
|
||||
/* 00D0 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_mapObjDefLinkList;
|
||||
/* 00DC */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_entityLinkList;
|
||||
/* 00E8 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_lightLinkList;
|
||||
/* 00F4 */ TSList<SI2SoundHandle, TSGetExplicitLink<SI2SoundHandle> > m_soundHandleList;
|
||||
/* 0100 */ TSExplicitList<CChunkLiquid, offsetof(CChunkLiquid, m_chunkLink)> m_liquidChunkLinkList;
|
||||
/* 010C */ uint8_t* m_chunkInfoBeginPtr;
|
||||
/* 0110 */ SMChunk* m_header;
|
||||
/* 0114 */ uint8_t* m_lowQualityTexMap;
|
||||
@@ -95,12 +102,33 @@ class CMapChunk : public CMapBaseObj {
|
||||
/* 0134 */ uint8_t* m_mcrfPtr;
|
||||
/* 0138 */ SMLiquidChunk* m_liquid;
|
||||
/* 013C */ CWSoundEmitter* m_soundEmitters;
|
||||
/* 0140 */ int32_t unk_0140;
|
||||
/* 0144 */ int32_t unk_0144;
|
||||
/* 0148 */ int32_t unk_0148;
|
||||
/* 014C */ int32_t unk_014C;
|
||||
/* 0150 */ int32_t unk_0150;
|
||||
/* 0154 */ int32_t unk_0154;
|
||||
/* 0140 */ CBitArray m_deepBits;
|
||||
/* 014C */ CBitArray m_fishableBits;
|
||||
|
||||
CMapChunk();
|
||||
void Create(SIffChunk* headerChunk, bool a3);
|
||||
void CreateRefs(CMapArea* mapChunk, uint32_t* mcrfPtr, uint32_t doodadRefs, uint32_t mapObjRefs);
|
||||
void ProcessIffChunks(bool a3);
|
||||
void CreateBounds();
|
||||
void RenderPrep();
|
||||
void Batch();
|
||||
void AllocRenderChunkAndBatch();
|
||||
void CullAndBucketChunk();
|
||||
void Purge();
|
||||
void UpdateLights();
|
||||
void CreateLiquids(bool a3);
|
||||
void CreateSoundEmitters(bool a3);
|
||||
void CreateDetailDoodads();
|
||||
void GetLiquidBounds(CAaBox& box) const;
|
||||
bool GetLiquidHeight(const C2Vector& pos, float* height) const;
|
||||
int16_t CreateIndices(char* buf, int32_t offset);
|
||||
void CreateIndices(uint16_t* buf, CGxBatch* batch);
|
||||
void CreateVertices(char* buf, int32_t vertexOffset, const C3Vector& offset);
|
||||
void CreateVerticesLocal(CGxVertexPN* buf);
|
||||
void CreateVerticesLocal(CGxVertexPNC* buf);
|
||||
void CreateVerticesWorld(CGxVertexPN* buf, const C3Vector& offset);
|
||||
void CreateVerticesWorld(CGxVertexPNC* buf, const C3Vector& offset);
|
||||
void Intersect(CiRect* rect, CFrustum* frustum, World::FacetData* facets);
|
||||
};
|
||||
|
||||
class CWSoundEmitter {
|
||||
|
||||
@@ -1 +1,597 @@
|
||||
#include "MapChunkLiquid.h"
|
||||
#include <cmath>
|
||||
#include "Engine/Source/Gx/CGxBuf.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/CGxPool.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/CChunkLiquid.h"
|
||||
#include "WoW/Source/WorldClient/FrameTime.h"
|
||||
#include "WoW/Source/WorldClient/LiquidEnvironment.h"
|
||||
#include "WoW/Source/WorldClient/LiquidGeomFactories.h"
|
||||
#include "WoW/Source/WorldClient/LiquidWaveManager.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapArea.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/MapChunk.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
|
||||
// STATIC: 0x00AF0A0C
|
||||
TSList<CMapChunkLiquid, TSGetExplicitLink<CMapChunkLiquid> > CMapChunkLiquidBuf::s_freeLists = TSExplicitList<CMapChunkLiquid, offsetof(CMapChunkLiquid, m_link)>();
|
||||
|
||||
// STATIC: 0x00D2DD2C
|
||||
Liquid::CWaveManager* CChunkLiquid::s_waveManager;
|
||||
|
||||
// STATIC: 0x00D2DD30
|
||||
int32_t CChunkLiquid::s_waveManagerRefs;
|
||||
|
||||
// VERIFY: da69d24e auto
|
||||
// OFFSET: 0x007CDE10
|
||||
void CChunkLiquid::Purge() {
|
||||
if (this->m_instance) {
|
||||
this->m_instance->Release();
|
||||
this->m_instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 0d06cb60 auto
|
||||
// OFFSET: 0x007CDE30
|
||||
void CChunkLiquid::UpdateResourcePurging() {
|
||||
if (this->m_resPurgeTimer >= 2.0f) {
|
||||
if (this->m_instance) {
|
||||
this->m_instance->Purge();
|
||||
}
|
||||
|
||||
this->m_resPurgeTimer = -1.0f;
|
||||
}
|
||||
|
||||
if (this->m_resPurgeTimer >= 0.0f) {
|
||||
this->m_resPurgeTimer = FrameTime::s_tickTimeSec + this->m_resPurgeTimer;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: a8377593 manual
|
||||
// OFFSET: 0x007CDE80
|
||||
void CChunkLiquid::GetAaBox(CAaBox& box) const {
|
||||
box = this->m_owner->m_bbox;
|
||||
box.b.z = this->m_height.x;
|
||||
box.t.z = this->m_height.y;
|
||||
}
|
||||
|
||||
// VERIFY: ab9c5bab auto
|
||||
// OFFSET: 0x007CDF50
|
||||
bool CMapChunkLiquidBuf::Valid() const {
|
||||
return this->m_vertexBuf && this->m_vertexBuf->unk_001C && this->m_vertexBuf->unk_001D && this->m_indexBuf && this->m_indexBuf->unk_001C && this->m_indexBuf->unk_001D;
|
||||
}
|
||||
|
||||
// VERIFY: 8f8e7321 manual
|
||||
// OFFSET: 0x007CDF80
|
||||
void CChunkLiquid::CreateVertXY() {
|
||||
CMapChunk* owner = this->m_owner;
|
||||
int32_t chunkX = owner->m_cOffset.x;
|
||||
int32_t chunkY = owner->m_cOffset.y;
|
||||
int32_t beginY = this->m_tileBegin.y;
|
||||
int32_t rows = this->m_tileEnd.x - this->m_tileBegin.x + 1;
|
||||
int32_t beginX = this->m_tileBegin.x;
|
||||
int32_t cols = this->m_tileEnd.y - beginY + 1;
|
||||
|
||||
C3Vector* vert = this->m_verts;
|
||||
uint32_t index = 0;
|
||||
|
||||
float stepY = -(17066.666f - chunkX * 33.333332f - (17066.666f - (chunkX + 1) * 33.333332f)) * 0.125f;
|
||||
|
||||
for (int32_t row = 0; row < rows; row++) {
|
||||
float stepX = 0.125f * -(17066.666f - chunkY * 33.333332f - (17066.666f - (chunkY + 1) * 33.333332f));
|
||||
float x = (row + beginX) * stepX;
|
||||
|
||||
for (int32_t col = 0; col < cols; col++) {
|
||||
vert->x = x;
|
||||
vert->y = (col + beginY) * stepY;
|
||||
vert->z = this->m_vertexData->GetHeight(index++) - this->m_owner->m_topLeftCoords.z;
|
||||
vert++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 6dc3ffdb manual
|
||||
// OFFSET: 0x007CE0B0
|
||||
bool CChunkLiquid::GetHeight(const C2Vector& frac, const C2iVector& tile, float& height) const {
|
||||
if (tile.x < this->m_tileBegin.y || tile.y < this->m_tileBegin.x || tile.x > this->m_tileEnd.y || tile.y > this->m_tileEnd.x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t cols = this->m_tileEnd.y - this->m_tileBegin.y + 1;
|
||||
uint32_t index = (tile.x - this->m_tileBegin.y) + cols * (tile.y - this->m_tileBegin.x);
|
||||
uint32_t next = index + cols;
|
||||
|
||||
float h00 = this->m_vertexData->GetHeight(index);
|
||||
float h01 = this->m_vertexData->GetHeight(index + 1);
|
||||
float h10 = this->m_vertexData->GetHeight(next);
|
||||
float h11 = this->m_vertexData->GetHeight(next + 1);
|
||||
|
||||
float top = h00 + (h01 - h00) * frac.x;
|
||||
height = top + (h10 + (h11 - h10) * frac.x - top) * frac.y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// VERIFY: cf242b03 manual
|
||||
// OFFSET: 0x007CE180
|
||||
bool CChunkLiquid::GetTileInfo(const C2iVector& tile, int32_t* type, int32_t* flag6, int32_t* flag7) const {
|
||||
if (!this->m_tiles) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8_t* entry = &this->m_tiles[tile.x + 8 * tile.y];
|
||||
*type = *entry & 0xF;
|
||||
*flag6 = (*entry >> 6) & 1;
|
||||
*flag7 = *entry >> 7;
|
||||
|
||||
return *type != 15 && ((*type ^ (this->m_type - 1)) & 3) == 0;
|
||||
}
|
||||
|
||||
// VERIFY: b3cebac0 auto
|
||||
// OFFSET: 0x007CE1F0
|
||||
bool CChunkLiquid::TileExists(uint32_t x, uint32_t y) const {
|
||||
if (this->m_tiles) {
|
||||
C2iVector tile;
|
||||
tile.x = x;
|
||||
tile.y = y;
|
||||
|
||||
int32_t type;
|
||||
int32_t flag6;
|
||||
int32_t flag7;
|
||||
|
||||
return this->GetTileInfo(tile, &type, &flag6, &flag7);
|
||||
}
|
||||
|
||||
if (x < static_cast<uint32_t>(this->m_tileBegin.y)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return y >= static_cast<uint32_t>(this->m_tileBegin.x) && x < static_cast<uint32_t>(this->m_tileEnd.y) && y < static_cast<uint32_t>(this->m_tileEnd.x) && this->m_tileBits.Get(x + (this->m_tileEnd.y - this->m_tileBegin.y) * (y - this->m_tileBegin.x) - this->m_tileBegin.y);
|
||||
}
|
||||
|
||||
// VERIFY: 51ae5fe3 manual
|
||||
// OFFSET: 0x007CE270
|
||||
void CChunkLiquid::BuildIndices(uint16_t* indices, uint16_t baseVertex, CGxBatch* batch) const {
|
||||
uint16_t* out = indices;
|
||||
uint16_t vertex = baseVertex;
|
||||
uint16_t below = baseVertex + this->m_tileEnd.y - this->m_tileBegin.y + 1;
|
||||
uint16_t last = 0;
|
||||
int32_t inStrip = 0;
|
||||
|
||||
for (int32_t row = this->m_tileBegin.x; row < this->m_tileEnd.x; row++) {
|
||||
uint16_t belowNext = below + 1;
|
||||
|
||||
for (int32_t col = this->m_tileBegin.y; col < this->m_tileEnd.y; col++) {
|
||||
if (this->TileExists(col, row)) {
|
||||
if (!inStrip) {
|
||||
*out++ = vertex;
|
||||
*out++ = vertex;
|
||||
*out++ = below;
|
||||
inStrip = 1;
|
||||
}
|
||||
|
||||
*out++ = vertex + 1;
|
||||
last = belowNext;
|
||||
*out++ = belowNext;
|
||||
} else if (inStrip) {
|
||||
inStrip = 0;
|
||||
*out++ = last;
|
||||
}
|
||||
|
||||
below++;
|
||||
belowNext++;
|
||||
vertex++;
|
||||
}
|
||||
|
||||
if (inStrip) {
|
||||
*out++ = last;
|
||||
inStrip = 0;
|
||||
}
|
||||
|
||||
below++;
|
||||
vertex++;
|
||||
}
|
||||
|
||||
batch->m_count += out - indices;
|
||||
}
|
||||
|
||||
// VERIFY: a801c800 manual
|
||||
// OFFSET: 0x007CE390
|
||||
void CChunkLiquid::BuildVertices(const C44Matrix* transform, uint32_t stride, C3Vector** position, C3Vector** normal, uint32_t** color, C2Vector** texCoord1, C2Vector** texCoord0) const {
|
||||
DepthCoordTable* depthCoords = CMap::GetDepthCoordTable(this->m_type);
|
||||
bool customTexCoords = this->unk_0008 == 1;
|
||||
uint32_t index = 0;
|
||||
int32_t rows = this->m_tileEnd.x - this->m_tileBegin.x + 1;
|
||||
const C3Vector* vert = this->m_verts;
|
||||
int32_t cols = this->m_tileEnd.y - this->m_tileBegin.y + 1;
|
||||
|
||||
for (int32_t row = 0; row < rows; row++) {
|
||||
for (int32_t col = 0; col < cols; col++) {
|
||||
C3Vector pos = *vert * *transform;
|
||||
|
||||
if (*position) {
|
||||
**position = pos;
|
||||
*position = reinterpret_cast<C3Vector*>(reinterpret_cast<uint8_t*>(*position) + stride);
|
||||
}
|
||||
|
||||
if (*normal) {
|
||||
(*normal)->x = 0.0f;
|
||||
(*normal)->y = 0.0f;
|
||||
(*normal)->z = 1.0f;
|
||||
*normal = reinterpret_cast<C3Vector*>(reinterpret_cast<uint8_t*>(*normal) + stride);
|
||||
}
|
||||
|
||||
if (*color) {
|
||||
**color = 0xFFFFFFFF;
|
||||
*color = reinterpret_cast<uint32_t*>(reinterpret_cast<uint8_t*>(*color) + stride);
|
||||
}
|
||||
|
||||
if (*texCoord1) {
|
||||
if (depthCoords) {
|
||||
uint8_t depth = this->m_vertexData->GetDepth(index);
|
||||
(*texCoord1)->x = 0.0f;
|
||||
(*texCoord1)->y = (*depthCoords)[depth];
|
||||
} else {
|
||||
(*texCoord1)->x = 0.0f;
|
||||
(*texCoord1)->y = 0.0f;
|
||||
}
|
||||
|
||||
*texCoord1 = reinterpret_cast<C2Vector*>(reinterpret_cast<uint8_t*>(*texCoord1) + stride);
|
||||
}
|
||||
|
||||
if (*texCoord0) {
|
||||
if (customTexCoords) {
|
||||
const uint16_t* uv = this->m_vertexData->GetTexCoord(index);
|
||||
(*texCoord0)->x = 0.01171875f * uv[0];
|
||||
(*texCoord0)->y = uv[1] * 0.01171875f;
|
||||
} else {
|
||||
(*texCoord0)->x = 0.060000002f * pos.x;
|
||||
(*texCoord0)->y = pos.y * 0.060000002f;
|
||||
}
|
||||
|
||||
*texCoord0 = reinterpret_cast<C2Vector*>(reinterpret_cast<uint8_t*>(*texCoord0) + stride);
|
||||
}
|
||||
|
||||
vert++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: ef77a0e3 manual
|
||||
// OFFSET: 0x007CE520
|
||||
CAaSphere* CChunkLiquid::GetSphere() {
|
||||
if (this->m_sphere.r < 0.0f) {
|
||||
CAaBox& bbox = this->m_owner->m_bbox;
|
||||
float top = this->m_height.y;
|
||||
|
||||
this->m_sphere.c = C3Vector((bbox.b.x + bbox.t.x) * 0.5f, (bbox.b.y + bbox.t.y) * 0.5f, 0.5f * (this->m_height.x + top));
|
||||
|
||||
float dy = bbox.t.y - this->m_sphere.c.y;
|
||||
float dx = bbox.t.x - this->m_sphere.c.x;
|
||||
this->m_sphere.r = sqrtf(dx * dx + dy * dy + (top - this->m_sphere.c.z) * (top - this->m_sphere.c.z));
|
||||
}
|
||||
|
||||
return &this->m_sphere;
|
||||
}
|
||||
|
||||
// INLINED
|
||||
CMapChunkLiquidBuf::CMapChunkLiquidBuf() {
|
||||
this->unk_0000 = 0;
|
||||
this->m_flushTimer = 0.0f;
|
||||
this->m_vertexDataSize = 0;
|
||||
this->m_indexDataSize = 0;
|
||||
this->m_vertexBuf = nullptr;
|
||||
this->m_indexBuf = nullptr;
|
||||
this->m_vertexPool = nullptr;
|
||||
this->m_indexPool = nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 1c787e83 manual
|
||||
// OFFSET: 0x007CED30
|
||||
CMapChunkLiquidBuf::~CMapChunkLiquidBuf() {
|
||||
if (this->m_vertexBuf) {
|
||||
CGxBuf* buf = this->m_vertexBuf;
|
||||
|
||||
if (buf != g_theGxDevicePtr->BufStream(buf->m_pool->m_target, 0, 0)) {
|
||||
g_theGxDevicePtr->BufDestroy(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_indexBuf) {
|
||||
CGxBuf* buf = this->m_indexBuf;
|
||||
|
||||
if (buf != g_theGxDevicePtr->BufStream(buf->m_pool->m_target, 0, 0)) {
|
||||
g_theGxDevicePtr->BufDestroy(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_vertexPool) {
|
||||
g_theGxDevicePtr->PoolDestroy(this->m_vertexPool);
|
||||
}
|
||||
|
||||
if (this->m_indexPool) {
|
||||
g_theGxDevicePtr->PoolDestroy(this->m_indexPool);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 61df3203 manual
|
||||
// OFFSET: 0x007CEE10
|
||||
CChunkLiquid::CChunkLiquid() {
|
||||
this->m_tileBegin.x = 0;
|
||||
this->m_tileBegin.y = 0;
|
||||
this->m_tileEnd.x = 0;
|
||||
this->m_tileEnd.y = 0;
|
||||
this->m_resPurgeTimer = 0.0f;
|
||||
this->m_type = 0;
|
||||
this->m_sphere.r = -1.0f;
|
||||
this->m_vertexData = nullptr;
|
||||
this->m_tiles = nullptr;
|
||||
this->m_instance = nullptr;
|
||||
this->m_owner = nullptr;
|
||||
|
||||
if (CChunkLiquid::s_waveManagerRefs == 0) {
|
||||
Liquid::CWaveManager* waveManager = Liquid::CWaveManager::Create();
|
||||
CChunkLiquid::s_waveManagerRefs++;
|
||||
CChunkLiquid::s_waveManager = waveManager;
|
||||
} else {
|
||||
CChunkLiquid::s_waveManager->AddRef();
|
||||
CChunkLiquid::s_waveManagerRefs++;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 10ec5edc manual
|
||||
// OFFSET: 0x007CEEF0
|
||||
CChunkLiquid::~CChunkLiquid() {
|
||||
if (CChunkLiquid::s_waveManagerRefs) {
|
||||
CChunkLiquid::s_waveManager->Release();
|
||||
CChunkLiquid::s_waveManagerRefs--;
|
||||
}
|
||||
|
||||
if (this->m_vertexData) {
|
||||
delete this->m_vertexData;
|
||||
this->m_vertexData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 86f2eb61 manual
|
||||
// OFFSET: 0x007CEFD0
|
||||
CMapChunkLiquidBuf* CMapChunkLiquidBuf::CreateBuf(uint32_t vertexCount, uint32_t indexCount, int32_t a3, uint32_t vertexSize) {
|
||||
void* mem = SMemAlloc(sizeof(CMapChunkLiquidBuf), __FILE__, __LINE__, 0);
|
||||
|
||||
if (!mem) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CMapChunkLiquidBuf* buf = new (mem) CMapChunkLiquidBuf();
|
||||
|
||||
CGxPool* vertexPool = g_theGxDevicePtr->PoolCreate(GxPoolTarget_Vertex, GxPoolUsage_Dynamic, vertexSize * vertexCount, GxPoolHintBit_Unk3, "CChunkBuf_Vertex");
|
||||
CGxPool* indexPool = g_theGxDevicePtr->PoolCreate(GxPoolTarget_Index, GxPoolUsage_Dynamic, 2 * indexCount, GxPoolHintBit_Unk3, "CChunkBuf_Index");
|
||||
CGxBuf* vertexBuf = g_theGxDevicePtr->BufCreate(vertexPool, vertexSize, vertexCount, 0);
|
||||
CGxBuf* indexBuf = g_theGxDevicePtr->BufCreate(indexPool, 2, indexCount, 0);
|
||||
|
||||
buf->m_flushTimer = 0.0f;
|
||||
buf->m_indexDataSize = 2 * indexCount;
|
||||
buf->unk_0000 = a3;
|
||||
buf->m_vertexPool = vertexPool;
|
||||
buf->m_vertexDataSize = vertexSize * vertexCount;
|
||||
buf->m_indexBuf = indexBuf;
|
||||
buf->m_indexPool = indexPool;
|
||||
buf->m_vertexBuf = vertexBuf;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// INLINED
|
||||
CMapChunkLiquid::CMapChunkLiquid() {
|
||||
}
|
||||
|
||||
// VERIFY: 3a225d8f manual
|
||||
// OFFSET: 0x007CF0C0
|
||||
CMapChunkLiquid::~CMapChunkLiquid() {
|
||||
}
|
||||
|
||||
// VERIFY: ac9225a1 manual
|
||||
// OFFSET: 0x007CF140
|
||||
CMapChunkLiquidBuf* CMapChunkLiquidBuf::Alloc(uint32_t vertexCount, uint32_t indexCount, int32_t a3, EGxVertexBufferFormat format) {
|
||||
uint32_t vertexSize = GxVertexSize(format);
|
||||
|
||||
for (CMapChunkLiquid* list = CMapChunkLiquidBuf::s_freeLists.Head(); list; list = CMapChunkLiquidBuf::s_freeLists.Next(list)) {
|
||||
if (list->m_vertexDataSize == vertexCount * vertexSize && list->m_indexDataSize == 2 * indexCount && list->m_liquids.Head()) {
|
||||
CMapChunkLiquidBuf* buf = list->m_liquids.Head();
|
||||
buf->m_link.Unlink();
|
||||
buf->m_vertexBuf->unk_001C = 0;
|
||||
buf->m_indexBuf->unk_001C = 0;
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
return CMapChunkLiquidBuf::CreateBuf(vertexCount, indexCount, a3, vertexSize);
|
||||
}
|
||||
|
||||
// VERIFY: e344dd13 manual
|
||||
// OFFSET: 0x007CF200
|
||||
void CChunkLiquid::Batch() {
|
||||
static TSGrowableArray<CChunkLiquid*> s_batch;
|
||||
|
||||
s_batch.Clear();
|
||||
s_batch.ReallocData(32);
|
||||
|
||||
if (CMap::enableChunkBatching) {
|
||||
CMapArea* area = static_cast<CMapArea*>(this->m_owner->m_parentLinkList.Head()->m_ref);
|
||||
CMapChunk** row = &area->m_mapChunks[16 * (this->m_owner->m_aIndex.y & ~1) + (this->m_owner->m_aIndex.x & ~1)];
|
||||
|
||||
for (int32_t y = 0; y < 2; y++) {
|
||||
CMapChunk** slot = row;
|
||||
|
||||
for (int32_t x = 0; x < 2; x++) {
|
||||
CMapChunk* chunk = *slot;
|
||||
|
||||
for (CChunkLiquid* liquid = chunk->m_liquidChunkLinkList.Head(); liquid; liquid = chunk->m_liquidChunkLinkList.Next(liquid)) {
|
||||
if (liquid->m_type == this->m_type) {
|
||||
s_batch.New(liquid);
|
||||
}
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
row += 16;
|
||||
}
|
||||
} else {
|
||||
CChunkLiquid* self = this;
|
||||
s_batch.New(self);
|
||||
}
|
||||
|
||||
CAaBox bounds;
|
||||
Liquid::CChunkGeomFactory* factory = Liquid::CChunkGeomFactory::Create(s_batch);
|
||||
|
||||
for (uint32_t i = 0; i < s_batch.m_count; i++) {
|
||||
CChunkLiquid* liquid = s_batch.m_data[i];
|
||||
|
||||
C2Vector minXY = C2Vector(liquid->m_topLeftCoords);
|
||||
minXY.x = minXY.x + liquid->m_tileBegin.y * 4.1666665f;
|
||||
minXY.y = minXY.y + 4.1666665f * liquid->m_tileBegin.x;
|
||||
C2Vector maxXY = C2Vector(liquid->m_topLeftCoords);
|
||||
maxXY.x = maxXY.x + liquid->m_tileEnd.y * 4.1666665f;
|
||||
maxXY.y = maxXY.y + 4.1666665f * liquid->m_tileEnd.x;
|
||||
|
||||
CAaBox box(C3Vector(minXY.x, minXY.y, liquid->m_height.x), C3Vector(maxXY.x, maxXY.y, liquid->m_height.y));
|
||||
|
||||
if (i) {
|
||||
bounds.t.z = bounds.t.z > box.t.z ? bounds.t.z : box.t.z;
|
||||
bounds.t.y = bounds.t.y > box.t.y ? bounds.t.y : box.t.y;
|
||||
bounds.t.x = bounds.t.x > box.t.x ? bounds.t.x : box.t.x;
|
||||
bounds.b.z = bounds.b.z < box.b.z ? bounds.b.z : box.b.z;
|
||||
bounds.b.y = bounds.b.y < box.b.y ? bounds.b.y : box.b.y;
|
||||
bounds.b.x = bounds.b.x < box.b.x ? bounds.b.x : box.b.x;
|
||||
} else {
|
||||
bounds = box;
|
||||
}
|
||||
}
|
||||
|
||||
C44Matrix transform;
|
||||
transform.Translate(s_batch.m_data[0]->m_topLeftCoords);
|
||||
|
||||
Liquid::CInstance* instance = Liquid::CInstance::Create();
|
||||
instance->m_material = Liquid::CMaterialBank::GetMaterial(this->m_type);
|
||||
instance->m_settings = Liquid::CSettingsBank::GetSettings(this->m_type);
|
||||
Liquid::CClientEnvironment* environment = Liquid::CClientEnvironment::Create(0);
|
||||
instance->m_geomFactory = factory;
|
||||
instance->m_environment = environment;
|
||||
instance->m_waveManager = CChunkLiquid::s_waveManager;
|
||||
CChunkLiquid::s_waveManager->AddRef();
|
||||
instance->m_transform = transform;
|
||||
|
||||
float dx = bounds.t.x - bounds.b.x;
|
||||
float dy = bounds.t.y - bounds.b.y;
|
||||
float dz = bounds.t.z - bounds.b.z;
|
||||
instance->m_bounds.c.x = (bounds.b.x + bounds.t.x) * 0.5f;
|
||||
instance->m_bounds.c.y = (bounds.t.y + bounds.b.y) * 0.5f;
|
||||
instance->m_bounds.c.z = (bounds.b.z + bounds.t.z) * 0.5f;
|
||||
instance->m_bounds.r = 0.5f * sqrtf(dy * dy + dx * dx + dz * dz);
|
||||
|
||||
for (uint32_t i = 0; i < s_batch.m_count; i++) {
|
||||
s_batch.m_data[i]->m_instance = instance;
|
||||
instance->AddRef();
|
||||
}
|
||||
|
||||
instance->Release();
|
||||
}
|
||||
|
||||
// VERIFY: 0f8f770e manual
|
||||
// OFFSET: 0x007CF790
|
||||
void CMapChunkLiquidBuf::Free(CMapChunkLiquidBuf* buf) {
|
||||
CMapChunkLiquid* list;
|
||||
|
||||
for (list = CMapChunkLiquidBuf::s_freeLists.Head(); list; list = CMapChunkLiquidBuf::s_freeLists.Next(list)) {
|
||||
if (list->m_vertexDataSize == buf->m_vertexDataSize && list->m_indexDataSize == buf->m_indexDataSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!list) {
|
||||
void* mem = SMemAlloc(sizeof(CMapChunkLiquid), __FILE__, __LINE__, 0);
|
||||
list = mem ? new (mem) CMapChunkLiquid() : nullptr;
|
||||
list->m_vertexDataSize = buf->m_vertexDataSize;
|
||||
list->m_indexDataSize = buf->m_indexDataSize;
|
||||
CMapChunkLiquidBuf::s_freeLists.LinkToTail(list);
|
||||
}
|
||||
|
||||
list->m_liquids.LinkToTail(buf);
|
||||
}
|
||||
|
||||
// VERIFY: 9b76b6fd manual
|
||||
// OFFSET: 0x007CF840
|
||||
void CMapChunkLiquidBuf::Update(float elapsed) {
|
||||
CMapChunkLiquid* list = CMapChunkLiquidBuf::s_freeLists.Head();
|
||||
|
||||
while (list) {
|
||||
CMapChunkLiquid* nextList = CMapChunkLiquidBuf::s_freeLists.Next(list);
|
||||
|
||||
CMapChunkLiquidBuf* buf = list->m_liquids.Head();
|
||||
|
||||
while (buf) {
|
||||
CMapChunkLiquidBuf* next = list->m_liquids.Next(buf);
|
||||
|
||||
if (!(buf->unk_0000 & 0x1)) {
|
||||
buf->m_flushTimer += elapsed;
|
||||
|
||||
if (buf->m_flushTimer > 5.0f) {
|
||||
buf->m_link.Unlink();
|
||||
delete buf;
|
||||
}
|
||||
}
|
||||
|
||||
buf = next;
|
||||
}
|
||||
|
||||
if (!list->m_liquids.Head()) {
|
||||
list->m_link.Unlink();
|
||||
delete list;
|
||||
}
|
||||
|
||||
list = nextList;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 3c1420a2 auto
|
||||
// OFFSET: 0x007CF9A0
|
||||
void CChunkLiquid::RenderPrep() {
|
||||
if (!this->m_instance) {
|
||||
this->Batch();
|
||||
}
|
||||
|
||||
if (this->m_instance && this->m_instance->m_waveManager) {
|
||||
static_cast<Liquid::CWaveManager*>(this->m_instance->m_waveManager)->PrepareRenderTransform(World::GetCamPos());
|
||||
}
|
||||
|
||||
this->m_resPurgeTimer = 0.0f;
|
||||
}
|
||||
|
||||
// VERIFY: 87f4391a manual
|
||||
// OFFSET: 0x007CF9E0
|
||||
void CMap::FreeAllChunkLiquids() {
|
||||
CMapChunkLiquid* list = CMapChunkLiquidBuf::s_freeLists.Head();
|
||||
|
||||
while (list) {
|
||||
CMapChunkLiquid* nextList = CMapChunkLiquidBuf::s_freeLists.Next(list);
|
||||
CMapChunkLiquidBuf* buf = list->m_liquids.Head();
|
||||
|
||||
while (buf) {
|
||||
CMapChunkLiquidBuf* next = list->m_liquids.Next(buf);
|
||||
buf->m_link.Unlink();
|
||||
delete buf;
|
||||
buf = next;
|
||||
}
|
||||
|
||||
list->m_link.Unlink();
|
||||
delete list;
|
||||
list = nextList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <windows.h>
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
|
||||
struct CGxBuf;
|
||||
@@ -13,6 +13,13 @@ class CMapChunkLiquid;
|
||||
|
||||
class CMapChunkLiquidBuf {
|
||||
public:
|
||||
static TSList<CMapChunkLiquid, TSGetExplicitLink<CMapChunkLiquid> > s_freeLists;
|
||||
|
||||
static CMapChunkLiquidBuf* Alloc(uint32_t vertexCount, uint32_t indexCount, int32_t a3, EGxVertexBufferFormat format);
|
||||
static CMapChunkLiquidBuf* CreateBuf(uint32_t vertexCount, uint32_t indexCount, int32_t a3, uint32_t vertexSize);
|
||||
static void Free(CMapChunkLiquidBuf* buf);
|
||||
static void Update(float elapsed);
|
||||
|
||||
/* 0000 */ uint32_t unk_0000;
|
||||
/* 0004 */ float m_flushTimer;
|
||||
/* 0008 */ uint32_t m_vertexDataSize;
|
||||
@@ -21,16 +28,22 @@ class CMapChunkLiquidBuf {
|
||||
/* 0014 */ CGxBuf* m_indexBuf;
|
||||
/* 0018 */ CGxPool* m_vertexPool;
|
||||
/* 001C */ CGxPool* m_indexPool;
|
||||
/* 0020 */ uint32_t unk_0020;
|
||||
/* 0024 */ uint32_t unk_0024;
|
||||
/* 0020 */ TSLink<CMapChunkLiquidBuf> m_link;
|
||||
|
||||
CMapChunkLiquidBuf();
|
||||
~CMapChunkLiquidBuf();
|
||||
bool Valid() const;
|
||||
};
|
||||
|
||||
class CMapChunkLiquid {
|
||||
public:
|
||||
/* 0000 */ uint32_t m_vertexDataSize;
|
||||
/* 0004 */ uint32_t m_indexDataSize;
|
||||
/* 0008 */ TSExplicitList<CMapChunkLiquidBuf> m_liquids;
|
||||
/* 0008 */ TSExplicitList<CMapChunkLiquidBuf, offsetof(CMapChunkLiquidBuf, m_link)> m_liquids;
|
||||
/* 0014 */ TSLink<CMapChunkLiquid> m_link;
|
||||
|
||||
CMapChunkLiquid();
|
||||
~CMapChunkLiquid();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,133 @@
|
||||
#include "MapDoodadDef.h"
|
||||
#include "Engine/Source/Model2/M2Data.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "Engine/Source/Model2/M2Model.h"
|
||||
#include "Engine/Source/Model2/M2Shared.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/CWorldMath.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapChunk.h"
|
||||
#include "WoW/Source/WorldClient/MapLight.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/WorldView.h"
|
||||
|
||||
// OFFSET: 0x007B4FA0
|
||||
void CMapDoodadDef::ExtendBounds(CMapBaseObj* parent) {
|
||||
if (parent->m_type & 0x4) {
|
||||
CMapChunk* chunk = static_cast<CMapChunk*>(parent);
|
||||
chunk->m_bbox.t.z = this->m_bbox.t.z >= chunk->m_bbox.t.z ? this->m_bbox.t.z : chunk->m_bbox.t.z;
|
||||
} else if (parent->m_type & 0x10) {
|
||||
CMapObjDefGroup* group = static_cast<CMapObjDefGroup*>(parent);
|
||||
group->m_bbox |= this->m_bbox;
|
||||
|
||||
CMapBaseObjLink* link = group->m_parentLinkList.Head();
|
||||
static_cast<CMapObjDef*>(link->m_ref)->m_bbox |= this->m_bbox;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 3ef424d0 manual
|
||||
// OFFSET: 0x007B55E0
|
||||
void CMapDoodadDef::ExtendChunkBounds() {
|
||||
for (CMapBaseObjLink* link = this->m_parentLinkList.Head(); link; link = this->m_parentLinkList.Next(link)) {
|
||||
this->ExtendBounds(link->m_ref);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 2d4db79f manual
|
||||
// OFFSET: 0x007BDB10
|
||||
void CMapDoodadDef::UpdateBounds() {
|
||||
CAaBox box;
|
||||
CAaSphere sphere;
|
||||
sphere.r = 0.0f;
|
||||
CAaBox collisionBox;
|
||||
|
||||
if (this->m_model) {
|
||||
box = this->m_model->GetBoundingBox();
|
||||
sphere = this->m_model->GetBoundingSphere();
|
||||
|
||||
CM2Model* model = this->m_model;
|
||||
|
||||
if (!(model->m_shared->m_flags & 0x1)) {
|
||||
model->WaitForLoad(nullptr);
|
||||
}
|
||||
|
||||
collisionBox = model->m_shared->m_data->m_collisionBounds.m_extent;
|
||||
}
|
||||
|
||||
this->m_sphere.c = sphere.c * this->m_mat;
|
||||
this->m_sphere.r = this->m_scale * sphere.r;
|
||||
|
||||
if (box.b.x <= box.t.x || box.b.y <= box.t.y || box.b.z <= box.t.z) {
|
||||
CWorldMath::TransformAABox(this->m_mat, box, this->m_bbox);
|
||||
} else {
|
||||
this->m_bbox.b = this->m_position;
|
||||
this->m_bbox.t = this->m_position;
|
||||
}
|
||||
|
||||
CWorldMath::TransformAABox(this->m_mat, collisionBox, this->m_bboxDoodadDef);
|
||||
|
||||
C3Vector center;
|
||||
center.x = (collisionBox.t.x + collisionBox.b.x) * 0.5f;
|
||||
center.y = (collisionBox.t.y + collisionBox.b.y) * 0.5f;
|
||||
center.z = 0.5f * (collisionBox.t.z + collisionBox.b.z);
|
||||
this->m_vec2 = center * this->m_mat;
|
||||
|
||||
float size = this->m_bbox.t.x - this->m_bbox.b.x;
|
||||
|
||||
if (this->m_bbox.t.y - this->m_bbox.b.y >= size) {
|
||||
size = this->m_bbox.t.y - this->m_bbox.b.y;
|
||||
}
|
||||
|
||||
if (this->m_bbox.t.z - this->m_bbox.b.z >= size) {
|
||||
size = this->m_bbox.t.z - this->m_bbox.b.z;
|
||||
}
|
||||
|
||||
uint8_t fadeLevel;
|
||||
|
||||
for (fadeLevel = 0; fadeLevel < 4; fadeLevel++) {
|
||||
if (size <= CWorldView::s_fadeSize[fadeLevel]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->m_fadeLevel = fadeLevel;
|
||||
|
||||
if (!(CWorld::enables & Enable_NoAnimation) && fadeLevel < 3) {
|
||||
this->m_model->m_fFlags &= ~0x40u;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 6f062999 manual
|
||||
// OFFSET: 0x007C1150
|
||||
void CMapDoodadDef::SelectLights(CM2Lighting* lighting) {
|
||||
if (this->m_flags & 0x2) {
|
||||
lighting->AddAmbient(C3Vector(this->m_m2AmbietColor));
|
||||
lighting->AddDiffuse(C3Vector(this->m_m2DiffuseColor), CMapStaticEntity::s_interiorSunDir);
|
||||
} else {
|
||||
CM2Light* light = &CMap::s_mapLight->m_light;
|
||||
lighting->AddAmbient(light->m_ambColor);
|
||||
|
||||
float scale = this->m_diffuseLightScale;
|
||||
C3Vector dir = light->m_dir;
|
||||
lighting->AddDiffuse(C3Vector(light->m_dirColor.x * scale, light->m_dirColor.y * scale, scale * light->m_dirColor.z), dir);
|
||||
}
|
||||
|
||||
DayNight::DNInfo* dayNight = DayNight::GetInfo();
|
||||
|
||||
if (this->m_flags & 0x8000) {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fogInterior.m_color), dayNight->m_fogInterior.m_start, dayNight->m_fogInterior.m_end, dayNight->m_fogInterior.m_density);
|
||||
} else {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fog.m_color), dayNight->m_fog.m_start, dayNight->m_fog.m_end, dayNight->m_fog.m_density);
|
||||
}
|
||||
|
||||
if (this->m_flags & 0x2) {
|
||||
lighting->m_flags |= 0x8;
|
||||
} else {
|
||||
lighting->m_flags &= ~0x8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,47 +3,27 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
#include "WoW/Source/WorldClient/MapLoad.h"
|
||||
|
||||
class CM2Model;
|
||||
class CM2Lighting;
|
||||
class CMapBaseObj;
|
||||
class CMapObjDef;
|
||||
|
||||
class CMapDoodadDef : public CMapBaseObj {
|
||||
class CMapDoodadDef : public CMapStaticEntity {
|
||||
public:
|
||||
/* 0024 */ uint8_t m_fadeLevel;
|
||||
/* 0025 */ uint8_t m_culled;
|
||||
/* 0026 */ uint8_t unk_0026;
|
||||
/* 0027 */ uint8_t unk_0027;
|
||||
/* 0028 */ uint32_t m_unkFlags28;
|
||||
/* 002C */ int32_t m_unkCounter;
|
||||
/* 0030 */ float m_distToCameraPlane;
|
||||
/* 0034 */ CM2Model* m_model;
|
||||
/* 0038 */ CAaSphere m_sphere;
|
||||
/* 0048 */ CAaBox m_bboxStaticEntity;
|
||||
/* 0060 */ C3Vector m_vec2;
|
||||
/* 006C */ C3Vector m_position;
|
||||
/* 0078 */ float m_scale;
|
||||
/* 007C */ int32_t unk_007C;
|
||||
/* 0080 */ int32_t unk_0080;
|
||||
/* 0084 */ CImVector m_m2AmbietColor;
|
||||
/* 0088 */ CImVector m_m2DiffuseColor;
|
||||
/* 008C */ float m_diffuseLightScale;
|
||||
/* 0090 */ uint32_t m_uniqueId;
|
||||
/* 0094 */ void* unk_0094;
|
||||
/* 0098 */ void* unk_0098;
|
||||
/* 009C */ void* m_prevMapDoodadDef09c;
|
||||
/* 00A0 */ void* m_nextMapDoodadDef0a0;
|
||||
/* 00A4 */ int32_t unk_00A4;
|
||||
/* 00A8 */ TSLink<void> m_doodadDefLink;
|
||||
/* 00A8 */ TSLink<CMapDoodadDef> m_doodadDefLink;
|
||||
/* 00B0 */ int32_t m_cullPassStamp;
|
||||
/* 00B4 */ int32_t unk_00B4;
|
||||
/* 00B8 */ int32_t unk_00B8;
|
||||
/* 00BC */ int32_t unk_00BC;
|
||||
/* 00B8 */ uint64_t unk_00B8;
|
||||
/* 00C0 */ CAaBox m_bboxDoodadDef;
|
||||
/* 00D8 */ C44Matrix m_mat;
|
||||
/* 0118 */ C44Matrix m_identity;
|
||||
@@ -53,6 +33,15 @@ class CMapDoodadDef : public CMapBaseObj {
|
||||
/* 0164 */ int32_t unk_0164;
|
||||
/* 0168 */ int32_t unk_0168;
|
||||
/* 016C */ int32_t unk_016C;
|
||||
|
||||
virtual void SelectLights(CM2Lighting* lighting);
|
||||
virtual void SelectUnderwater(CM2Lighting* lighting);
|
||||
virtual bool QueryInteriorLighting(CMapObjDef* mapObjDef, int32_t groupNum, uint16_t* faceIndex, C3Vector* pos);
|
||||
|
||||
CMapDoodadDef();
|
||||
void UpdateBounds();
|
||||
void ExtendBounds(CMapBaseObj* parent);
|
||||
void ExtendChunkBounds();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,128 @@
|
||||
#include "MapEntity.h"
|
||||
#include "WoW/Source/WorldClient/MapLight.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
|
||||
// STATIC: 0x00ADEEBC
|
||||
float CMapStaticEntity::s_characterAmbient = 1.0f;
|
||||
|
||||
// STATIC: 0x00AEEDF0
|
||||
C3Vector CMapStaticEntity::s_interiorSunDir = C3Vector(-0.30822f, -0.30822f, -0.9f);
|
||||
|
||||
// VERIFY: b7c5af51 manual
|
||||
// OFFSET: 0x007A0B50
|
||||
CMapStaticEntity::CMapStaticEntity() {
|
||||
this->m_sphere.c = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_sphere.r = 0.0f;
|
||||
this->m_scale = 0.0f;
|
||||
this->unk_007C &= 0xFFFE4000;
|
||||
this->m_distanceToCamera = 0.0f;
|
||||
this->unk_0080 = 0.0f;
|
||||
this->m_model = nullptr;
|
||||
this->m_diffuseLightScale = 0.0f;
|
||||
this->m_unkCounter = 0;
|
||||
this->unk_0028 = 0;
|
||||
this->unk_0029 = 0;
|
||||
this->unk_002A = 0;
|
||||
this->unk_002B = 0;
|
||||
this->m_fadeLevel = 0;
|
||||
this->m_vec2 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->unk_0025 = 2;
|
||||
}
|
||||
|
||||
// VERIFY: eeb1ad46 manual
|
||||
// OFFSET: 0x007A0FE0
|
||||
CMapEntity::CMapEntity() {
|
||||
this->unk_00A8 = C3Vector(0.0f, 0.0f, 0.0f);
|
||||
this->m_func = nullptr;
|
||||
this->m_funcParam = nullptr;
|
||||
this->m_funcParam64 = 0;
|
||||
this->m_funcParam32 = 0;
|
||||
this->unk_00B4 = 0;
|
||||
this->m_groundType = 0;
|
||||
this->unk_00BC = 0;
|
||||
this->unk_00BE = 0;
|
||||
this->unk_00A4 = 0xFFFFFFFF;
|
||||
this->unk_00C0.b = 0xFF;
|
||||
this->unk_00C0.g = 0x00;
|
||||
this->unk_00C0.r = 0x00;
|
||||
this->unk_00C0.a = 0x00;
|
||||
this->unk_00C4 = 0.0f;
|
||||
this->m_type |= 0x20;
|
||||
}
|
||||
|
||||
// VERIFY: d83b5d3e manual
|
||||
// OFFSET: 0x007C1730
|
||||
void CMapStaticEntity::SelectLights(CM2Lighting* lighting) {
|
||||
if (CWorld::farFog > this->m_distanceToCamera) {
|
||||
if (this->m_flags & MAPOBJ_FLAG_UNPLACED) {
|
||||
this->m_flags = static_cast<MapObjFlag>(this->m_flags & ~MAPOBJ_FLAG_UNPLACED);
|
||||
}
|
||||
|
||||
C3Vector diffuse = { 0.0f, 0.0f, 0.0f };
|
||||
C3Vector dir = { 0.0f, 0.0f, 0.0f };
|
||||
C3Vector ambient = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
if ((this->m_flags & 4) != 0) {
|
||||
CM2Light* light = &CMap::s_mapLight->m_light;
|
||||
|
||||
diffuse.x = light->m_dirColor.x * this->m_diffuseLightScale;
|
||||
diffuse.y = light->m_dirColor.y * this->m_diffuseLightScale;
|
||||
diffuse.z = light->m_dirColor.z * this->m_diffuseLightScale;
|
||||
|
||||
dir = light->m_dir;
|
||||
|
||||
ambient = C3Vector(this->m_m2AmbietColor);
|
||||
} else {
|
||||
diffuse = C3Vector(this->m_m2DiffuseColor);
|
||||
diffuse.x *= this->m_diffuseLightScale;
|
||||
diffuse.y *= this->m_diffuseLightScale;
|
||||
diffuse.z *= this->m_diffuseLightScale;
|
||||
|
||||
ambient = C3Vector(this->m_m2AmbietColor);
|
||||
|
||||
dir = CMapStaticEntity::s_interiorSunDir;
|
||||
|
||||
if ((this->unk_007C & 0x1000) != 0) {
|
||||
DayNight::DNInfo* dayNight = DayNight::GetInfo();
|
||||
float blend = this->m_m2DiffuseColor.a / 255.0f;
|
||||
|
||||
dir.x += (dayNight->m_light1.m_dir.x - dir.x) * blend;
|
||||
dir.y += (dayNight->m_light1.m_dir.y - dir.y) * blend;
|
||||
dir.z += (dayNight->m_light1.m_dir.z - dir.z) * blend;
|
||||
|
||||
dir.Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
if ((this->unk_007C & 0x8000) != 0) {
|
||||
ambient.x *= CMapStaticEntity::s_characterAmbient;
|
||||
ambient.y *= CMapStaticEntity::s_characterAmbient;
|
||||
ambient.z *= CMapStaticEntity::s_characterAmbient;
|
||||
|
||||
if (ambient.x >= 1.0f) {
|
||||
ambient.x = 1.0f;
|
||||
}
|
||||
|
||||
if (ambient.y >= 1.0f) {
|
||||
ambient.y = 1.0f;
|
||||
}
|
||||
|
||||
if (ambient.z >= 1.0f) {
|
||||
ambient.z = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
lighting->AddAmbient(ambient);
|
||||
lighting->AddDiffuse(diffuse, dir);
|
||||
}
|
||||
|
||||
DayNight::DNInfo* dayNight = DayNight::GetInfo();
|
||||
|
||||
if ((this->m_flags & 0x8000) != 0) {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fogInterior.m_color), dayNight->m_fogInterior.m_start, dayNight->m_fogInterior.m_end, dayNight->m_fogInterior.m_density);
|
||||
} else {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fog.m_color), dayNight->m_fog.m_start, dayNight->m_fog.m_end, dayNight->m_fog.m_density);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/MapLoad.h"
|
||||
|
||||
class CMapObjDef;
|
||||
|
||||
class CMapEntity : public CMapStaticEntity {
|
||||
public:
|
||||
/* 0090 */ uint32_t (__cdecl* m_func )(uint32_t, uint32_t, uint64_t, uint32_t);
|
||||
@@ -13,15 +17,20 @@ class CMapEntity : public CMapStaticEntity {
|
||||
/* 0098 */ uint64_t m_funcParam64;
|
||||
/* 00A0 */ uint32_t m_funcParam32;
|
||||
/* 00A4 */ uint32_t unk_00A4;
|
||||
/* 00A8 */ uint32_t unk_00A8;
|
||||
/* 00AC */ uint32_t unk_00AC;
|
||||
/* 00B0 */ uint32_t unk_00B0;
|
||||
/* 00A8 */ C3Vector unk_00A8;
|
||||
/* 00B4 */ uint32_t unk_00B4;
|
||||
/* 00B8 */ uint32_t unk_00B8;
|
||||
/* 00BC */ uint32_t unk_00BC;
|
||||
/* 00C0 */ uint32_t unk_00C0;
|
||||
/* 00C4 */ uint32_t unk_00C4;
|
||||
/* 00B8 */ int32_t m_groundType;
|
||||
/* 00BC */ uint16_t unk_00BC;
|
||||
/* 00BE */ uint16_t unk_00BE;
|
||||
/* 00C0 */ CImVector unk_00C0;
|
||||
/* 00C4 */ float unk_00C4;
|
||||
/* 00C8 */ TSLink<void> m_sortEntryLink;
|
||||
|
||||
virtual bool QueryInteriorLighting(CMapObjDef* mapObjDef, int32_t groupNum, uint16_t* faceIndex, C3Vector* pos);
|
||||
|
||||
CMapEntity();
|
||||
void QueryLiquidSounds(uint32_t* results, uint32_t* distance);
|
||||
bool UpdateMapObjLiquid();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,32 +3,27 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
|
||||
class CMapLight : public CMapBaseObj {
|
||||
public:
|
||||
/* 0024 */ float unk_0024;
|
||||
/* 0028 */ float unk_0028;
|
||||
/* 002C */ float unk_002C;
|
||||
/* 0030 */ float unk_0030;
|
||||
/* 0034 */ float unk_0034;
|
||||
/* 0038 */ float unk_0038;
|
||||
/* 003C */ float unk_003C;
|
||||
/* 0040 */ float unk_0040;
|
||||
/* 0044 */ float unk_0044;
|
||||
/* 0048 */ float unk_0048;
|
||||
/* 004C */ float unk_004C;
|
||||
/* 0050 */ float unk_0050;
|
||||
/* 0054 */ float unk_0054;
|
||||
/* 0024 */ C3Vector m_position;
|
||||
/* 0030 */ CAaBox m_bbox;
|
||||
/* 0048 */ CAaSphere m_sphere;
|
||||
/* 0058 */ CM2Light m_light;
|
||||
/* 00C4 */ float unk_00C4;
|
||||
/* 00C8 */ float unk_00C8;
|
||||
/* 00C8 */ float m_radius;
|
||||
/* 00CC */ float unk_00CC;
|
||||
/* 00D0 */ uint8_t unk_00D0;
|
||||
/* 00D1 */ uint8_t unk_00D1;
|
||||
/* 00D2 */ uint8_t unk_00D2;
|
||||
/* 00D3 */ uint8_t unk_00D3;
|
||||
|
||||
CMapLight();
|
||||
};
|
||||
|
||||
class CMapCacheLight {
|
||||
|
||||
@@ -1 +1,25 @@
|
||||
#include "MapLoad.h"
|
||||
#include "Engine/Source/Model2/M2Model.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
|
||||
// VERIFY: 1ce54c55 manual
|
||||
// OFFSET: 0x00780CD0
|
||||
void CMapStaticEntity::ModelLightingCallback(CM2Model* model, CM2Lighting* lighting, void* userArg) {
|
||||
CMapStaticEntity* entity = reinterpret_cast<CMapStaticEntity*>(userArg);
|
||||
|
||||
lighting->m_flags |= 0x10;
|
||||
auto dayNight = DayNight::GetInfo();
|
||||
if (entity) {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fog.m_color), dayNight->m_fog.m_start, dayNight->m_fog.m_end, dayNight->m_fog.m_density);
|
||||
entity->SelectLights(lighting);
|
||||
entity->SelectUnderwater(lighting);
|
||||
if ((entity->m_flags & MAPOBJ_FLAG_INTERIOR) != 0) {
|
||||
lighting->m_flags |= 8;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
lighting->AddAmbient(C3Vector(dayNight->m_light1.m_ambient));
|
||||
lighting->AddDiffuse(C3Vector(dayNight->m_light1.m_diffuse), dayNight->m_light1.m_dir);
|
||||
}
|
||||
lighting->m_flags &= ~8u;
|
||||
}
|
||||
|
||||
@@ -9,15 +9,26 @@
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
|
||||
class CM2Lighting;
|
||||
class CMapObjDef;
|
||||
|
||||
class CM2Model;
|
||||
|
||||
class CMapStaticEntity : public CMapBaseObj {
|
||||
public:
|
||||
/* 0024 */ uint8_t unk_0024;
|
||||
static float s_characterAmbient;
|
||||
static C3Vector s_interiorSunDir;
|
||||
|
||||
static void ModelLightingCallback(CM2Model* model, CM2Lighting* lighting, void* userArg);
|
||||
|
||||
/* 0024 */ uint8_t m_fadeLevel;
|
||||
/* 0025 */ uint8_t unk_0025;
|
||||
/* 0026 */ uint8_t unk_0026;
|
||||
/* 0027 */ uint8_t unk_0027;
|
||||
/* 0028 */ uint32_t m_unkFlags28;
|
||||
/* 0028 */ uint8_t unk_0028;
|
||||
/* 0029 */ uint8_t unk_0029;
|
||||
/* 002A */ uint8_t unk_002A;
|
||||
/* 002B */ uint8_t unk_002B;
|
||||
/* 002C */ int32_t m_unkCounter;
|
||||
/* 0030 */ float m_distanceToCamera;
|
||||
/* 0034 */ CM2Model* m_model;
|
||||
@@ -26,11 +37,17 @@ class CMapStaticEntity : public CMapBaseObj {
|
||||
/* 0060 */ C3Vector m_vec2;
|
||||
/* 006C */ C3Vector m_position;
|
||||
/* 0078 */ float m_scale;
|
||||
/* 007C */ int32_t unk_007C;
|
||||
/* 0080 */ int32_t unk_0080;
|
||||
/* 007C */ uint32_t unk_007C;
|
||||
/* 0080 */ float unk_0080;
|
||||
/* 0084 */ CImVector m_m2AmbietColor;
|
||||
/* 0088 */ CImVector m_m2DiffuseColor;
|
||||
/* 008C */ float unk_008C;
|
||||
/* 008C */ float m_diffuseLightScale;
|
||||
|
||||
virtual void SelectLights(CM2Lighting* lighting);
|
||||
virtual void SelectUnderwater(CM2Lighting* lighting);
|
||||
virtual bool QueryInteriorLighting(CMapObjDef* mapObjDef, int32_t groupNum, uint16_t* faceIndex, C3Vector* pos) = 0;
|
||||
|
||||
CMapStaticEntity();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,173 @@
|
||||
#include "MapLowDetail.h"
|
||||
#include <cmath>
|
||||
#include "Engine/Source/BlizzardCore/SFile2-Core.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/WorldClient/FVBBList.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapArea.h"
|
||||
#include "WoW/Source/WorldClient/MapObj.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
|
||||
// VERIFY: pending
|
||||
// VERIFY: a9a4e286 manual
|
||||
// OFFSET: 0x007C06E0
|
||||
CMapAreaLow::CMapAreaLow() {
|
||||
this->m_index.x = 0;
|
||||
this->m_index.y = 0;
|
||||
this->unk_004C = 0;
|
||||
this->unk_0050 = 0;
|
||||
this->m_indexCount = 0;
|
||||
this->m_block = nullptr;
|
||||
this->unk_0058 = 0;
|
||||
this->m_heights = nullptr;
|
||||
this->m_holes = nullptr;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007CBFE0
|
||||
void CMapLowDetail::Purge() {
|
||||
for (uint32_t i = 0; i < 4096; i++) {
|
||||
CMapAreaLow* areaLow = this->m_areas[i];
|
||||
|
||||
if (areaLow) {
|
||||
if (areaLow->m_block) {
|
||||
CMap::s_vbbList.Release(areaLow->m_block);
|
||||
}
|
||||
|
||||
this->m_areas[i]->m_block = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: pending
|
||||
// VERIFY: ba76c774 manual
|
||||
// OFFSET: 0x007CC310
|
||||
void CMapLowDetail::Load(const char* mapPath, const char* mapName) {
|
||||
char fileName[256];
|
||||
SFileImpl* file;
|
||||
|
||||
SStrPrintf(fileName, sizeof(fileName), "%s\\%s.wdl", mapPath, mapName);
|
||||
SFileOpenFile(fileName, &file);
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t size = SFileGetFileSize(file, nullptr);
|
||||
this->m_data = static_cast<char*>(SMemAlloc(size, __FILE__, __LINE__, 0));
|
||||
SFileReadFile(file, this->m_data, size, nullptr, nullptr, 0);
|
||||
SFileCloseFile(file);
|
||||
|
||||
uint32_t* chunk = reinterpret_cast<uint32_t*>(this->m_data + reinterpret_cast<uint32_t*>(this->m_data)[1] + 8);
|
||||
char* data = this->m_data + reinterpret_cast<uint32_t*>(this->m_data)[1] + 16;
|
||||
|
||||
if (chunk[0] == 0x4D574D4F) {
|
||||
this->m_mapObjNames = data;
|
||||
uint32_t* mwid = reinterpret_cast<uint32_t*>(data + chunk[1]);
|
||||
this->m_mapObjNameOffsets = mwid + 2;
|
||||
uint32_t* modf = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(mwid) + mwid[1] + 8);
|
||||
this->m_mapObjDefs = reinterpret_cast<SMMapObjDef*>(modf + 2);
|
||||
this->m_mapObjDefCount = modf[1] >> 6;
|
||||
data = reinterpret_cast<char*>(modf + 2) + modf[1] + 8;
|
||||
}
|
||||
|
||||
this->m_areaOffsets = reinterpret_cast<uint32_t*>(data);
|
||||
|
||||
uint32_t index = 0;
|
||||
|
||||
for (uint32_t y = 0; y < 1024; y += 16) {
|
||||
for (uint32_t x = 0; x < 1024; x += 16) {
|
||||
if (this->m_areaOffsets[index]) {
|
||||
char* mare = this->m_data + this->m_areaOffsets[index];
|
||||
CMapAreaLow* area = CMap::AllocAreaLow();
|
||||
this->m_areas[index] = area;
|
||||
area->m_heights = reinterpret_cast<int16_t*>(mare + 8);
|
||||
uint32_t* next = reinterpret_cast<uint32_t*>(mare + reinterpret_cast<uint32_t*>(mare)[1] + 8);
|
||||
|
||||
int32_t minHeight = 100000;
|
||||
int32_t maxHeight = -100000;
|
||||
|
||||
for (uint32_t i = 0; i < 545; i++) {
|
||||
int32_t height = area->m_heights[i];
|
||||
|
||||
if (height > maxHeight) {
|
||||
maxHeight = height;
|
||||
}
|
||||
|
||||
if (height < minHeight) {
|
||||
minHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
area->m_index.x = x >> 4;
|
||||
area->m_index.y = y >> 4;
|
||||
|
||||
float top = 17066.666f - static_cast<float>(y) * 33.333332f;
|
||||
area->m_topLeft.x = top;
|
||||
area->m_bbox.t.x = top;
|
||||
|
||||
float left = static_cast<float>(x) * -33.333332f + 17066.666f;
|
||||
area->m_topLeft.y = left;
|
||||
area->m_bbox.t.y = left;
|
||||
area->m_bbox.t.z = static_cast<float>(maxHeight);
|
||||
area->m_bbox.b.x = top - 533.33331f;
|
||||
area->m_bbox.b.y = left - 533.33331f;
|
||||
area->m_bbox.b.z = static_cast<float>(minHeight);
|
||||
|
||||
area->m_sphere.c.x = (area->m_bbox.t.x + area->m_bbox.b.x) * 0.5f;
|
||||
area->m_sphere.c.y = (area->m_bbox.b.y + area->m_bbox.t.y) * 0.5f;
|
||||
area->m_sphere.c.z = 0.5f * (area->m_bbox.b.z + area->m_bbox.t.z);
|
||||
float dz = area->m_bbox.t.z - area->m_sphere.c.z;
|
||||
float dy = area->m_bbox.t.y - area->m_sphere.c.y;
|
||||
float dx = area->m_bbox.t.x - area->m_sphere.c.x;
|
||||
area->m_sphere.r = sqrtf(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (next[0] == 0x4D41484F) {
|
||||
uint16_t* holes = reinterpret_cast<uint16_t*>(next + 2);
|
||||
area->m_holes = holes;
|
||||
area->m_indexCount = 0;
|
||||
|
||||
for (uint32_t row = 0; row < 16; row++) {
|
||||
for (uint32_t bit = 0; bit < 16; bit++) {
|
||||
if (!((1 << bit) & holes[row])) {
|
||||
area->m_indexCount += 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
area->m_holes = nullptr;
|
||||
area->m_indexCount = 3072;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
C3Vector center(17066.666f, 17066.666f, 0.0f);
|
||||
this->m_mapObjDefList.SetCount(this->m_mapObjDefCount);
|
||||
|
||||
for (uint32_t i = 0; i < this->m_mapObjDefCount; i++) {
|
||||
SMMapObjDef* def = &this->m_mapObjDefs[i];
|
||||
CMapObjDef* mapObjDef = CMap::CreateMapObjDef(this->m_mapObjNames + this->m_mapObjNameOffsets[def->m_nameId], def, ¢er, false);
|
||||
|
||||
if (!CMap::s_isStreamingMode) {
|
||||
CMapObj* mapObj = mapObjDef->m_owner;
|
||||
|
||||
if (!mapObj->m_isGroupLoaded) {
|
||||
mapObj->WaitLoad();
|
||||
}
|
||||
|
||||
uint32_t groupCount = mapObj->m_groupInfoCount;
|
||||
|
||||
for (uint32_t group = 0; group < groupCount; group++) {
|
||||
if (!mapObj->IsGroupLoaded(group)) {
|
||||
mapObj->ReadGroup(group);
|
||||
mapObj->WaitLoadGroup(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mapObjDef->m_refCount++;
|
||||
this->m_mapObjDefList.m_data[i] = mapObjDef;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,49 @@
|
||||
#ifndef WOW_SOURCE_WORLDCLIENT_MAPLOWDETAIL_H
|
||||
#define WOW_SOURCE_WORLDCLIENT_MAPLOWDETAIL_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "WoW/Source/WorldClient/FVBBList.h"
|
||||
|
||||
class CMapObjDef;
|
||||
struct SMMapObjDef;
|
||||
|
||||
class CMapAreaLow {
|
||||
public:
|
||||
/* 0000 */ uint32_t m_objectIndex;
|
||||
/* 0004 */ CAaBox m_bbox;
|
||||
/* 001C */ CAaSphere m_sphere;
|
||||
/* 002C */ C3Vector m_topLeft;
|
||||
/* 0038 */ C2iVector m_index;
|
||||
/* 0040 */ uint32_t m_indexCount;
|
||||
/* 0044 */ int16_t* m_heights;
|
||||
/* 0048 */ uint16_t* m_holes;
|
||||
/* 004C */ uint32_t unk_004C;
|
||||
/* 0050 */ uint32_t unk_0050;
|
||||
/* 0054 */ FVBBList::Block* m_block;
|
||||
/* 0058 */ uint32_t unk_0058;
|
||||
|
||||
CMapAreaLow();
|
||||
};
|
||||
|
||||
class CMapLowDetail {
|
||||
public:
|
||||
/* 0000 */ char* m_data;
|
||||
/* 0004 */ char* m_mapObjNames;
|
||||
/* 0008 */ uint32_t* m_mapObjNameOffsets;
|
||||
/* 000C */ SMMapObjDef* m_mapObjDefs;
|
||||
/* 0010 */ uint32_t m_mapObjDefCount;
|
||||
/* 0014 */ uint32_t* m_areaOffsets;
|
||||
/* 0018 */ CMapAreaLow* m_areas [4096];
|
||||
/* 4018 */ TSGrowableArray<CMapObjDef*> m_mapObjDefList;
|
||||
|
||||
void Load(const char* mapPath, const char* mapName);
|
||||
void Purge();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1,8 @@
|
||||
#include "MapMem.h"
|
||||
#include "WoW/Source/WorldClient/MapArea.h"
|
||||
|
||||
// VERIFY: bffb685d manual
|
||||
// OFFSET: 0x007BFE40
|
||||
void* CMapArea::AllocAsyncLoadBuffer(int32_t fileSize) {
|
||||
return SMemAlloc(fileSize, __FILE__, __LINE__, 0);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,46 @@
|
||||
#include "MapObj.h"
|
||||
#include "Engine/Source/Tempest/C2Vector.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "Engine/Source/Base/ObjectAlloc.h"
|
||||
#include "Engine/Source/ShaderEffect/ShaderEffectManager.h"
|
||||
#include "Engine/Source/Storm/H/storm.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
#include <cmath>
|
||||
#include "Engine/Source/Services/AsyncFile.h"
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Tempest/C3Segment.h"
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Tempest/C4Plane.h"
|
||||
#include "Engine/Source/Tempest/C4Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Tempest/CFrustum.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "Engine/Source/Gx/CGxBuf.h"
|
||||
#include "Engine/Source/Gx/CGxLight.h"
|
||||
#include "Engine/Source/Gx/CGxTex.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/MapDoodadDef.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
#include "Engine/Source/ShaderEffect/ShaderEffect.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/CWorldMath.h"
|
||||
#include "WoW/Source/WorldClient/MapChunk.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
#include "Engine/Source/Base/CDataAllocator.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/BlizzardCore/Source/Packages/Mopaq/SFile.h"
|
||||
#include "Engine/Source/DayNight/DayNight.h"
|
||||
#include "WoW/Source/WorldClient/MapRenderChunk.h"
|
||||
#include "Engine/Source/Services/Texture.h"
|
||||
#include "Engine/Source/Gxu/GxuLight.h"
|
||||
|
||||
// STATIC: 0x00AEE008
|
||||
uint32_t CMapObj::s_unk_AEE008 = 2;
|
||||
|
||||
// STATIC: 0x00ADFF50
|
||||
static int32_t unk_ADFF50 = 2048;
|
||||
@@ -29,17 +66,122 @@ int32_t CMapObj::bPoolsDirty;
|
||||
// STATIC: 0x00D1C41C
|
||||
CMapObjDef* s_stampedMapObjDef;
|
||||
|
||||
// STATIC: 0x00D1C420
|
||||
CMapObjDef* s_curMapObjDef;
|
||||
|
||||
// STATIC: 0x00D1C424
|
||||
uint32_t s_portalStamp;
|
||||
|
||||
// VERIFY: 2a9f3c91 manual
|
||||
// STATIC: 0x00D1C428
|
||||
static HASHKEY_NONE s_mapObjHashKey;
|
||||
|
||||
// VERIFY: bd88db75 auto
|
||||
// OFFSET: 0x007A7B00
|
||||
static void __stdcall WriteLiquidVertex(CMapObjGroup* group, const C44Matrix& matrix, const C3Vector& vertex, const SMOLiquidVert* liquidVert, const CImVector* color, int32_t magma, float texCoord1U, int32_t* unused, uint32_t stride, C3Vector** position, C3Vector** normal, CImVector** vertexColor, C2Vector** texCoord0, C2Vector** texCoord1) {
|
||||
DepthCoordTable* depthTable = CMap::GetDepthCoordTable(group->m_liquidType);
|
||||
|
||||
if (*position) {
|
||||
**position = vertex * matrix;
|
||||
*position = reinterpret_cast<C3Vector*>(reinterpret_cast<uint8_t*>(*position) + stride);
|
||||
}
|
||||
|
||||
if (*normal) {
|
||||
(*normal)->x = 0.0f;
|
||||
(*normal)->y = 0.0f;
|
||||
(*normal)->z = 1.0f;
|
||||
*normal = reinterpret_cast<C3Vector*>(reinterpret_cast<uint8_t*>(*normal) + stride);
|
||||
}
|
||||
|
||||
if (*vertexColor) {
|
||||
CImVector value;
|
||||
|
||||
if (g_theGxDevicePtr->Caps().m_colorFormat == GxCF_rgba) {
|
||||
value.b = color->r;
|
||||
value.g = color->g;
|
||||
value.r = color->b;
|
||||
value.a = color->a;
|
||||
} else {
|
||||
value = *color;
|
||||
}
|
||||
|
||||
**vertexColor = value;
|
||||
*vertexColor = reinterpret_cast<CImVector*>(reinterpret_cast<uint8_t*>(*vertexColor) + stride);
|
||||
}
|
||||
|
||||
if (*texCoord0) {
|
||||
if (magma) {
|
||||
(*texCoord0)->x = liquidVert->m_magmaVert.m_s * 0.00390625f;
|
||||
(*texCoord0)->y = liquidVert->m_magmaVert.m_t * 0.00390625f;
|
||||
} else {
|
||||
C44Matrix rotation = matrix;
|
||||
rotation.d0 = 0.0f;
|
||||
rotation.d1 = 0.0f;
|
||||
rotation.d2 = 0.0f;
|
||||
rotation.d3 = 1.0f;
|
||||
|
||||
C3Vector local;
|
||||
local.x = vertex.x - group->m_liquidCorner.x;
|
||||
local.y = vertex.y - group->m_liquidCorner.y;
|
||||
local.z = vertex.z - group->m_liquidCorner.z;
|
||||
|
||||
C2Vector uv(local * rotation);
|
||||
(*texCoord0)->x = uv.x * 0.24f;
|
||||
(*texCoord0)->y = 0.24f * uv.y;
|
||||
}
|
||||
|
||||
*texCoord0 = reinterpret_cast<C2Vector*>(reinterpret_cast<uint8_t*>(*texCoord0) + stride);
|
||||
}
|
||||
|
||||
if (*texCoord1) {
|
||||
float depth = depthTable ? (*depthTable)[liquidVert->m_waterVert.m_flow1] : 0.0f;
|
||||
(*texCoord1)->x = texCoord1U;
|
||||
(*texCoord1)->y = depth;
|
||||
*texCoord1 = reinterpret_cast<C2Vector*>(reinterpret_cast<uint8_t*>(*texCoord1) + stride);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: f7f5970e auto
|
||||
// OFFSET: 0x007AE1A0
|
||||
void CMapObj::ReadGroup(uint32_t index) {
|
||||
this->ReadGroup(index, false);
|
||||
}
|
||||
|
||||
// VERIFY: d92cbc0c auto
|
||||
// OFFSET: 0x007AE1C0
|
||||
void CMapObj::WaitLoad() {
|
||||
while (this->m_asyncObject) {
|
||||
AsyncFileReadWait(this->m_asyncObject);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: c6f5dc77 manual
|
||||
// OFFSET: 0x007AE4C0
|
||||
int32_t CMapObj::IsGroupLoaded(int32_t index) {
|
||||
if (this->m_isGroupLoaded) {
|
||||
return this->m_mapObjGroupArray[index]->m_unkLoadedFlag & 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// VERIFY: 8c25cdca manual
|
||||
// OFFSET: 0x007AE7E0
|
||||
bool CMapObj::TestBounds(CAaBox& box) {
|
||||
return this->m_isGroupLoaded && this->m_bbox.Intersects(box);
|
||||
}
|
||||
|
||||
// VERIFY: 0d13eb33 auto
|
||||
// OFFSET: 0x007AEAB0
|
||||
void CMapObj::WaitLoadGroup(uint32_t index) {
|
||||
CMapObjGroup* group = this->m_mapObjGroupArray[index];
|
||||
|
||||
while (group->m_asyncObjPtr) {
|
||||
AsyncFileReadWait(group->m_asyncObjPtr);
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: baf76f3a manual
|
||||
// OFFSET: 0x007AFEE0
|
||||
void CMapObj::Initialize() {
|
||||
s_portalStamp = 0;
|
||||
s_curMapObjDef = nullptr;
|
||||
CWorldScene::s_curMapObjDef = nullptr;
|
||||
s_stampedMapObjDef = nullptr;
|
||||
unk_ADFF50 = 2048;
|
||||
unk_D1BEE8.Reserve(1024, 0);
|
||||
@@ -103,3 +245,297 @@ void CMapObj::ClearCache(int32_t a1) {
|
||||
mapObj = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// OFFSET: 0x007A8800
|
||||
void CMapObj::SetRenderModeLight() {
|
||||
CGxLight light;
|
||||
light.m_flags |= 0x1;
|
||||
|
||||
float d = 1.0f / sqrtf(3.0f);
|
||||
light.m_dir = { d, d, d };
|
||||
light.m_ambientColor = { 0.33f, 0.33f, 0.33f };
|
||||
light.m_dirColor = { 0.75f, 0.75f, 0.75f };
|
||||
light.m_specularColor = { 0.0f, 0.0f, 0.0f };
|
||||
light.m_constantAttenuation = 0.0f;
|
||||
light.m_linearAttenuation = 0.0f;
|
||||
light.m_quadraticAttenuation = 0.0f;
|
||||
|
||||
C3Vector origin = { 0.0f, 0.0f, 0.0f };
|
||||
g_theGxDevicePtr->LightSet(0, light, origin);
|
||||
g_theGxDevicePtr->LightEnable(0, 1);
|
||||
|
||||
for (int i = 1; i < 4; i++)
|
||||
g_theGxDevicePtr->LightEnable(i, 0);
|
||||
|
||||
GxRsSet(GxRs_Lighting, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// OFFSET: 0x007AE140
|
||||
uint32_t CMapObj::CreateWmoIgnoreFlags(uint32_t a1) {
|
||||
uint32_t result = 0xEE;
|
||||
if ((a1 & 0x80u) != 0)
|
||||
return 0x2CA;
|
||||
if ((a1 & 0x10) != 0)
|
||||
result = 0xC6;
|
||||
if ((a1 & 0x20) != 0)
|
||||
result &= 0xDBu;
|
||||
if ((a1 & 0x40) == 0)
|
||||
result &= ~2u;
|
||||
if ((a1 & 0x4000) == 0)
|
||||
result &= ~0x40u;
|
||||
if ((a1 & 0x1000000) != 0) {
|
||||
if ((a1 & 0x40000000) != 0)
|
||||
return 0xFFFFFCDB;
|
||||
else
|
||||
return result | 0x100;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: 81665f7f manual
|
||||
// OFFSET: 0x0079BBF0
|
||||
void CMapObj::QueryLiquidSounds(uint32_t groupIndex, uint32_t fromGroup, uint32_t depth, uint32_t* minDepth, const C3Vector& pos, uint32_t* results) {
|
||||
if (depth > CMapObj::s_unk_AEE008) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->GetGroupInfo(groupIndex)->m_boundingBox.ContainsPoint(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CMapObjGroup* group = this->GetGroup(groupIndex, false);
|
||||
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((group->m_flags & 0x8) && depth < *minDepth) {
|
||||
*minDepth = depth;
|
||||
}
|
||||
|
||||
group->QueryLiquidSounds(pos, results);
|
||||
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(group->m_portalCount); i++) {
|
||||
uint32_t neighbor = this->m_portalRefList[group->m_portalStart + i].m_groupIndex;
|
||||
|
||||
if (neighbor != 0xFFFF && neighbor != fromGroup) {
|
||||
this->QueryLiquidSounds(neighbor, groupIndex, depth + 1, minDepth, pos, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 3402cfca auto
|
||||
// OFFSET: 0x007A6D70
|
||||
SMOMaterial* CMapObj::GetLiquidMaterial(int32_t groupIndex) {
|
||||
CMapObjGroup* group = this->GetGroup(groupIndex, false);
|
||||
|
||||
if (!group) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &this->m_materialList[static_cast<uint16_t>(group->m_luquidMaterialId)];
|
||||
}
|
||||
|
||||
// VERIFY: 64db3118 auto
|
||||
// OFFSET: 0x007AEB90
|
||||
bool CMapObj::QueryLiquidStatus(uint32_t ignoreFlags, const C3Vector& pos, int32_t* liquidType, float* level) {
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(this->m_groupInfoCount); i++) {
|
||||
if (!this->m_isGroupLoaded) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SMOGroupInfo* info = &this->m_groupInfo[i];
|
||||
|
||||
if (!info || (ignoreFlags & info->m_flags) || !info->m_boundingBox.ContainsPoint(pos)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CMapObjGroup* group = this->m_mapObjGroupArray[i];
|
||||
|
||||
if ((group->m_unkLoadedFlag & 0x1) && group->QueryLiquid(pos, liquidType, level)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// VERIFY: bad0310c manual
|
||||
// OFFSET: 0x007A7920
|
||||
void CMapObj::BuildLiquidIndices(CMapObjGroup* group, const TSGrowableArray<uint8_t>* sharedVerts, uint16_t** indices, uint16_t baseVertex) {
|
||||
int32_t rowStride = group->m_liquidVerts.x + sharedVerts[0].m_count;
|
||||
uint16_t lastIndex = 0;
|
||||
int32_t inStrip = 0;
|
||||
uint32_t sharedRow = 0;
|
||||
int32_t outRow = 0;
|
||||
|
||||
for (int32_t y = 0; y < group->m_liquidTiles.y; y++) {
|
||||
int32_t duplicate = 0;
|
||||
|
||||
if (sharedRow < sharedVerts[1].m_count && sharedVerts[1].m_data[sharedRow] == y) {
|
||||
duplicate = 1;
|
||||
sharedRow++;
|
||||
}
|
||||
|
||||
int32_t nextRow = baseVertex + rowStride;
|
||||
|
||||
for (int32_t r = duplicate + 1; r; r--) {
|
||||
uint16_t top = outRow * rowStride + baseVertex;
|
||||
uint16_t bottom = nextRow + top;
|
||||
uint32_t sharedCol = 0;
|
||||
|
||||
for (int32_t x = 0; x < group->m_liquidTiles.x; x++) {
|
||||
uint8_t flags = group->m_liquidTileList[group->m_liquidTiles.x * y + x].m_flags;
|
||||
int32_t visible = (flags & 0xF) != 0xF && (flags & 0x80) ? 1 : 0;
|
||||
int32_t duplicateCol = 0;
|
||||
|
||||
if (sharedCol < sharedVerts[0].m_count && sharedVerts[0].m_data[sharedCol] == x) {
|
||||
duplicateCol = 1;
|
||||
sharedCol++;
|
||||
}
|
||||
|
||||
uint16_t bottomNext = bottom + 1;
|
||||
|
||||
for (int32_t c = duplicateCol + 1; c; c--) {
|
||||
if (visible) {
|
||||
if (!inStrip) {
|
||||
inStrip = 1;
|
||||
*(*indices)++ = top;
|
||||
*(*indices)++ = top;
|
||||
*(*indices)++ = bottom;
|
||||
}
|
||||
|
||||
*(*indices)++ = top + 1;
|
||||
**indices = bottomNext;
|
||||
lastIndex = bottomNext;
|
||||
(*indices)++;
|
||||
} else if (inStrip) {
|
||||
**indices = lastIndex;
|
||||
inStrip = 0;
|
||||
(*indices)++;
|
||||
}
|
||||
|
||||
top++;
|
||||
bottom++;
|
||||
bottomNext++;
|
||||
}
|
||||
}
|
||||
|
||||
if (inStrip) {
|
||||
*(*indices)++ = lastIndex;
|
||||
inStrip = 0;
|
||||
}
|
||||
|
||||
outRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 5e3b42d7 manual
|
||||
// OFFSET: 0x007A7CC0
|
||||
uint16_t CMapObj::BuildLiquidVerts(CMapObjGroup* group, const C44Matrix& matrix, const CImVector* color, int32_t magma, float texCoord1U, const TSGrowableArray<uint8_t>* sharedVerts, uint32_t stride, C3Vector** position, C3Vector** normal, CImVector** vertexColor, C2Vector** texCoord0, C2Vector** texCoord1) {
|
||||
float y = group->m_liquidCorner.y;
|
||||
uint32_t sharedRow = 0;
|
||||
|
||||
for (int32_t row = 0; row < group->m_liquidVerts.y; row++) {
|
||||
int32_t duplicateRow = 0;
|
||||
|
||||
if (sharedRow < sharedVerts[1].m_count && sharedVerts[1].m_data[sharedRow] == row) {
|
||||
duplicateRow = 1;
|
||||
sharedRow++;
|
||||
}
|
||||
|
||||
for (int32_t r = duplicateRow + 1; r; r--) {
|
||||
float x = group->m_liquidCorner.x;
|
||||
uint32_t sharedCol = 0;
|
||||
|
||||
for (int32_t col = 0; col < group->m_liquidVerts.x; col++) {
|
||||
const SMOLiquidVert* liquidVert = &group->m_liquidVertexList[group->m_liquidVerts.x * row + col];
|
||||
|
||||
C3Vector vertex;
|
||||
vertex.x = x;
|
||||
vertex.y = y;
|
||||
vertex.z = liquidVert->m_waterVert.m_height;
|
||||
|
||||
int32_t duplicateCol = 0;
|
||||
|
||||
if (sharedCol < sharedVerts[0].m_count && sharedVerts[0].m_data[sharedCol] == col) {
|
||||
duplicateCol = 1;
|
||||
sharedCol++;
|
||||
}
|
||||
|
||||
int32_t unused;
|
||||
|
||||
for (int32_t c = duplicateCol + 1; c; c--) {
|
||||
WriteLiquidVertex(group, matrix, vertex, liquidVert, color, magma, texCoord1U, &unused, stride, position, normal, vertexColor, texCoord0, texCoord1);
|
||||
}
|
||||
|
||||
x += 4.1666665f;
|
||||
}
|
||||
}
|
||||
|
||||
y += 4.1666665f;
|
||||
}
|
||||
|
||||
return (group->m_liquidVerts.x + sharedVerts[0].m_count) * (sharedVerts[1].m_count + group->m_liquidVerts.y);
|
||||
}
|
||||
|
||||
// VERIFY: 3da651a7 auto
|
||||
// OFFSET: 0x007B0CC0
|
||||
CMapObj* CMapObj::Create(char* fileName) {
|
||||
uint32_t hashval = SStrHash(fileName, 0, 0);
|
||||
CMapObj* mapObj = CMapObj::mapObjHash.Ptr(hashval, s_mapObjHashKey);
|
||||
|
||||
if (mapObj) {
|
||||
mapObj->m_refCount++;
|
||||
return mapObj;
|
||||
}
|
||||
|
||||
mapObj = CMap::AllocMapObj();
|
||||
|
||||
if (!mapObj->Read(fileName)) {
|
||||
DebugLog("CMapObj::Create(): mapObj->Read(\"%s\") failed", fileName);
|
||||
}
|
||||
|
||||
CMapObj::mapObjHash.Insert(mapObj, hashval, s_mapObjHashKey);
|
||||
mapObj->m_refCount = 1;
|
||||
|
||||
return mapObj;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
#include "Engine/Source/Tempest/CAaBox.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Tempest/CWFrustum.h"
|
||||
|
||||
class C2Vector;
|
||||
class C44Matrix;
|
||||
class CFrustum;
|
||||
class CMapObjDefGroup;
|
||||
struct C3Segment;
|
||||
|
||||
class C3Vector;
|
||||
class C4Plane;
|
||||
@@ -21,6 +28,7 @@ struct SMODoodadDef;
|
||||
struct SMODoodadSet;
|
||||
struct SMOFog;
|
||||
struct SMOGroupInfo;
|
||||
class CAaSphere;
|
||||
struct SMOHeader;
|
||||
struct SMOLight;
|
||||
struct SMOMaterial;
|
||||
@@ -39,17 +47,36 @@ class CMapObjIndex {
|
||||
/* 0000 */ int32_t m_objectIndex;
|
||||
};
|
||||
|
||||
typedef void (*RENDER_CALLBACK)(uint32_t, void*);
|
||||
|
||||
class CMapObj : public CMapObjIndex, public TSHashObject<CMapObj, HASHKEY_NONE> {
|
||||
public:
|
||||
static TSList<CMapObj, TSGetExplicitLink<CMapObj> > s_asyncLoadQueue;
|
||||
static TSList<CMapObjGroup, TSGetExplicitLink<CMapObjGroup> > s_unk_ADFC58;
|
||||
static TSHashTable<CMapObj, HASHKEY_NONE> mapObjHash;
|
||||
static int32_t bPoolsDirty;
|
||||
static uint32_t* occluderHeap;
|
||||
static CShaderEffect* s_classicShaders[7];
|
||||
static CShaderEffect* s_unifiedShaders[7];
|
||||
static uint32_t s_unk_AEE008;
|
||||
|
||||
static void ClearCache(int32_t a1);
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static uint32_t CreateWmoIgnoreFlags(uint32_t a1);
|
||||
static void PrepareUpdate();
|
||||
static CMapObj* Create(char* fileName);
|
||||
static void PostloadCallback(void* arg);
|
||||
static void RenderGroupCollidable(CMapObj* mapObj, CMapObjGroup* mapObjGroup, uint32_t a3);
|
||||
static void RenderGroupCollidableFaces(CMapObjGroup* mapObjGroup);
|
||||
static void ExteriorRender(CMapObj* mapObj, CMapObjGroup* mapObjGroup, uint32_t a3);
|
||||
static void InteriorRender(CMapObj* mapObj, CMapObjGroup* mapObjGroup, uint32_t a3);
|
||||
static void UnifiedRender(CMapObj* mapObj, CMapObjGroup* mapObjGroup, uint32_t a3);
|
||||
static void InvokeGroupRenderCallback(CMapObj* mapObj, uint32_t groupNum);
|
||||
static void SetGroupRenderCallback(RENDER_CALLBACK callback, void* param);
|
||||
static void SetRenderModeLight();
|
||||
static void SetEmissiveColor(CImVector color);
|
||||
static void SelectWorldShaders();
|
||||
|
||||
/* 001C */ char m_wmoName [260];
|
||||
/* 0120 */ SMOHeader* m_header;
|
||||
@@ -88,8 +115,7 @@ class CMapObj : public CMapObjIndex, public TSHashObject<CMapObj, HASHKEY_NONE>
|
||||
/* 01A4 */ int32_t unk_01A4;
|
||||
/* 01A8 */ CAaBox m_bbox;
|
||||
/* 01C0 */ float m_distToCamera;
|
||||
/* 01C4 */ int32_t unk_01C4;
|
||||
/* 01C8 */ int32_t unk_01C8;
|
||||
/* 01C4 */ TSLink<CMapObj> m_asyncLoadLink;
|
||||
/* 01CC */ void* m_pWmoData;
|
||||
/* 01D0 */ int32_t m_wmoFileSize;
|
||||
/* 01D4 */ int32_t m_refCount;
|
||||
@@ -100,6 +126,43 @@ class CMapObj : public CMapObjIndex, public TSHashObject<CMapObj, HASHKEY_NONE>
|
||||
/* 01E8 */ TSExplicitList<CMapObjGroup> m_mapObjGroupList;
|
||||
/* 01F4 */ int32_t m_mapObjGroupCount;
|
||||
/* 01F8 */ CMapObjGroup* m_mapObjGroupArray [512];
|
||||
|
||||
CMapObj();
|
||||
bool Read(char* fileName);
|
||||
void ReadGroup(uint32_t index);
|
||||
void ReadGroup(uint32_t index, bool preLoad);
|
||||
void Load();
|
||||
void WaitLoad();
|
||||
void WaitLoadGroup(uint32_t index);
|
||||
void GetBounds(CAaBox* box);
|
||||
void GetGroupBounds(CAaSphere* sphere, int32_t index);
|
||||
void GetGroupBounds(CAaBox* box, int32_t index);
|
||||
int32_t GetDoodadSet(uint16_t index);
|
||||
uint32_t GetGroupFlags(int32_t index);
|
||||
SMOGroupInfo* GetGroupInfo(int32_t index);
|
||||
int32_t IsGroupLoaded(int32_t index);
|
||||
char* GetGroupName(int32_t index);
|
||||
CMapObjGroup* GetGroup(int32_t index, bool a3);
|
||||
void RenderGroup(int32_t groupIndex, C44Matrix& matrix, TSExplicitList<CWFrustum, offsetof(CWFrustum, m_link)>* frustumList);
|
||||
void CreateRefs(CMapObjGroup* mapObjGroup, CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup);
|
||||
void CreateMaterial(uint8_t texture);
|
||||
void CreateMaterials();
|
||||
bool TestBounds(CAaBox& box);
|
||||
bool TestGroupBounds(C3Vector& start, C3Vector& end, uint32_t groupNum);
|
||||
bool TestGroupBounds(C3Vector& point, uint32_t groupNum);
|
||||
bool TestGroupBounds(CAaBox& box, uint32_t groupNum, int32_t a3);
|
||||
bool GroupBoundingBoxIntersectsSphere(C3Vector& pos, uint32_t groupNum, float radius);
|
||||
bool GetTris(CFrustum* frustum, uint32_t flags, uint32_t a4, CMapObjDef* mapObjDef);
|
||||
bool VectorIntersectPortal(C3Segment& seg, float* t, int* outGroups, int useSphereTest);
|
||||
bool VectorIntersectPortals(uint32_t groupNum, C3Segment& seg, float* t, int32_t* outGroups);
|
||||
float CalcPortalFarthestDistance(SMOPortal* portal);
|
||||
bool Intersect(C3Vector& start, C3Vector& end, float* distance, uint32_t flags, uint32_t ignoreFlags, uint32_t groupNum, int32_t* hitIndex);
|
||||
SMOMaterial* GetLiquidMaterial(int32_t groupIndex);
|
||||
bool QueryLiquidStatus(uint32_t ignoreFlags, const C3Vector& pos, int32_t* liquidType, float* level);
|
||||
void QueryLiquidSounds(uint32_t groupIndex, uint32_t fromGroup, uint32_t depth, uint32_t* minDepth, const C3Vector& pos, uint32_t* results);
|
||||
uint16_t BuildLiquidVerts(CMapObjGroup* group, const C44Matrix& matrix, const CImVector* color, int32_t magma, float texCoord1U, const TSGrowableArray<uint8_t>* sharedVerts, uint32_t stride, C3Vector** position, C3Vector** normal, CImVector** vertexColor, C2Vector** texCoord0, C2Vector** texCoord1);
|
||||
void BuildLiquidIndices(CMapObjGroup* group, const TSGrowableArray<uint8_t>* sharedVerts, uint16_t** indices, uint16_t baseVertex);
|
||||
uint16_t ClipGroupGeometry(CMapObjGroup* group, const C44Matrix& matrix, const CImVector* color, int32_t magma, float texCoord1U, uint32_t stride, C3Vector** position, C3Vector** normal, CImVector** vertexColor, C2Vector** texCoord0, C2Vector** texCoord1, uint16_t** indices, uint16_t baseVertex);
|
||||
};
|
||||
|
||||
struct SMOBatch {
|
||||
@@ -184,8 +247,8 @@ struct SMOVisibleBlock {
|
||||
/* 0002 */ uint16_t m_count;
|
||||
};
|
||||
|
||||
extern CMapObjDef* s_curMapObjDef;
|
||||
extern uint32_t s_portalStamp;
|
||||
extern CMapObjDef* s_stampedMapObjDef;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1 +1,40 @@
|
||||
#include "MapObjDef.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapLight.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/CWorldMath.h"
|
||||
#include "WoW/Source/WorldClient/DayNight__DNInfo.h"
|
||||
|
||||
// VERIFY: 18be6c93 auto
|
||||
// OFFSET: 0x007B3990
|
||||
bool CMapObjDef::TestAABox(C3Vector& start, C3Vector& end) {
|
||||
return CWorldMath::VectorIntersectAABox2(this->m_bbox, start, end);
|
||||
}
|
||||
|
||||
// VERIFY: 7ed1c1b6 manual
|
||||
// OFFSET: 0x007B3F30
|
||||
void CMapObjDefGroup::SelectLights(CM2Lighting* lighting) {
|
||||
lighting->AddLight(&CMap::s_mapLight->m_light);
|
||||
|
||||
if (CWorld::farFog > this->m_distanceToCamera) {
|
||||
if (this->m_flags & MAPOBJ_FLAG_UNPLACED) {
|
||||
this->m_flags = static_cast<MapObjFlag>(this->m_flags & ~MAPOBJ_FLAG_UNPLACED);
|
||||
}
|
||||
|
||||
for (CMapBaseObjLink* link = this->m_lightLinkList.Head(); link; link = this->m_lightLinkList.Next(link)) {
|
||||
CMapLight* light = static_cast<CMapLight*>(link->m_owner);
|
||||
|
||||
if (light->m_light.m_visible && !light->unk_00D1) {
|
||||
lighting->AddLight(&light->m_light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DayNight::DNInfo* dayNight = DayNight::GetInfo();
|
||||
|
||||
if (this->m_flags & 0x8000) {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fogInterior.m_color), dayNight->m_fogInterior.m_start, dayNight->m_fogInterior.m_end, dayNight->m_fogInterior.m_density);
|
||||
} else {
|
||||
lighting->SetFog(C3Vector(dayNight->m_fog.m_color), dayNight->m_fog.m_start, dayNight->m_fog.m_end, dayNight->m_fog.m_density);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/MapBaseObj.h"
|
||||
|
||||
class CM2Lighting;
|
||||
|
||||
class CMapObj;
|
||||
class CMapObjDefGroup;
|
||||
class CMapObjDefMapObjDefGroupLink;
|
||||
@@ -28,11 +30,9 @@ class CMapObjDefGroup : public CMapBaseObj {
|
||||
/* 0064 */ int32_t unk_0064;
|
||||
/* 0068 */ int32_t unk_0068;
|
||||
/* 006C */ TSList<void> m_frustumList;
|
||||
/* 0078 */ TSList<void> m_doodadDefLinkList;
|
||||
/* 0084 */ TSList<void> m_entityLinkList;
|
||||
/* 0090 */ uint32_t unk_0090;
|
||||
/* 0094 */ uint32_t unk_0094;
|
||||
/* 0098 */ uint32_t unk_0098;
|
||||
/* 0078 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_doodadDefLinkList;
|
||||
/* 0084 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_entityLinkList;
|
||||
/* 0090 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_lightLinkList;
|
||||
/* 009C */ uint32_t unk_009C;
|
||||
/* 00A0 */ uint32_t unk_00A0;
|
||||
/* 00A4 */ uint32_t unk_00A4;
|
||||
@@ -40,16 +40,16 @@ class CMapObjDefGroup : public CMapBaseObj {
|
||||
/* 00B0 */ TSLink<void> m_sortTableLink;
|
||||
/* 00B8 */ uint32_t unk_00B8;
|
||||
/* 00BC */ uint32_t unk_00BC;
|
||||
|
||||
virtual void SelectLights(CM2Lighting* lighting);
|
||||
|
||||
CMapObjDefGroup();
|
||||
void MarkPrepared();
|
||||
void UpdateLights();
|
||||
};
|
||||
|
||||
class CMapObjDef : public CMapBaseObj {
|
||||
class CMapObjDef : public CMapBaseObj, public TSHashObject<CMapObjDef, HASHKEY_NONE> {
|
||||
public:
|
||||
/* 0024 */ void* unk_0024;
|
||||
/* 0028 */ void* unk_0028;
|
||||
/* 002C */ void* unk_002C;
|
||||
/* 0030 */ void* unk_0030;
|
||||
/* 0034 */ void* unk_0034;
|
||||
/* 0038 */ int32_t unk_0038;
|
||||
/* 003C */ C3Vector m_position;
|
||||
/* 0048 */ CAaBox m_bbox;
|
||||
/* 0060 */ CAaSphere m_sphere;
|
||||
@@ -64,15 +64,19 @@ class CMapObjDef : public CMapBaseObj {
|
||||
/* 0108 */ int32_t unk_0108;
|
||||
/* 010C */ int32_t unk_010C;
|
||||
/* 0110 */ int32_t unk_0110;
|
||||
/* 0114 */ TSExplicitList<CMapObjDefMapObjDefGroupLink> m_mapObjDefGroupLinkList;
|
||||
/* 0120 */ TSGrowableArray<CMapObjDefGroup> m_defGroups;
|
||||
/* 0130 */ uint32_t m_groupCount;
|
||||
/* 0114 */ TSList<CMapBaseObjLink, TSGetExplicitLink<CMapBaseObjLink> > m_mapObjDefGroupLinkList;
|
||||
/* 0120 */ TSCGrowableArray<CMapObjDefGroup*, 4> m_defGroups;
|
||||
/* 0134 */ TSGrowableArray<uint8_t> m_lightsArray;
|
||||
/* 0144 */ uint32_t m_argbColor;
|
||||
/* 0148 */ int32_t unk_0148;
|
||||
/* 014C */ int32_t unk_014C;
|
||||
/* 0150 */ int16_t m_doodadSetOverrides [3];
|
||||
/* 0156 */ uint8_t unk_0156[2];
|
||||
|
||||
CMapObjDef();
|
||||
bool TestAABox(C3Vector& start, C3Vector& end);
|
||||
int32_t GetGroundType(uint32_t groupNum, uint16_t faceIndex);
|
||||
void RenderWithCallback(TSGrowableArray<uint16_t>* groups);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
#include "MapObjGroup.h"
|
||||
#include "Engine/Source/Gx/CGxBuf.h"
|
||||
#include <cmath>
|
||||
#include <malloc.h>
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
#include "Engine/Source/Tempest/C3Ray.h"
|
||||
#include "Engine/Source/Tempest/CiRect.h"
|
||||
#include "Engine/Source/Tempest/CMath.h"
|
||||
#include "Engine/Source/Tempest/CWFrustum.h"
|
||||
#include "Engine/Source/Tempest/NTempest.h"
|
||||
#include "WoW/Source/DB/DBClient/DBClient.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/CGxPool.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
|
||||
// STATIC: 0x00AEEE58
|
||||
VBBList CMapObjGroup::vertexVBList;
|
||||
@@ -13,6 +23,14 @@ VBBList CMapObjGroup::indexVBList;
|
||||
// STATIC: 0x00AEEEA8
|
||||
TSExplicitList<CMapObjGroup::VertArray, offsetof(CMapObjGroup::VertArray, m_link)> CMapObjGroup::s_unk_AEEEA8;
|
||||
|
||||
// VERIFY: 4f76965b auto
|
||||
// OFFSET: 0x007C7790
|
||||
static uint8_t CullLiquidVertexZ(const CAaBox& box, const C3Vector& vertex) {
|
||||
float below = vertex.z - box.b.z + 0.019444443f;
|
||||
float above = box.t.z - vertex.z + 0.019444443f;
|
||||
return ((*reinterpret_cast<uint32_t*>(&below) >> 29) & 0x4) | ((*reinterpret_cast<uint32_t*>(&above) >> 26) & 0x20);
|
||||
}
|
||||
|
||||
// VERIFY: 03d37c83 auto
|
||||
// OFFSET: 0x007CB990
|
||||
void CMapObjGroup::Initialize() {
|
||||
@@ -82,3 +100,806 @@ void CMapObjGroup::Destroy() {
|
||||
CMapObjGroup::indexVBList.Destroy();
|
||||
CMapObjGroup::s_unk_AEEEA8.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: af527478 manual
|
||||
// OFFSET: 0x007C8360
|
||||
bool CMapObjGroup::QueryLiquid(const C3Vector& pos, int32_t* liquidType, float* level) {
|
||||
int32_t type = this->m_liquidType;
|
||||
|
||||
if (!type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->m_liquidTiles.x || !this->m_liquidTiles.y) {
|
||||
*liquidType = type;
|
||||
*level = 3.4028235e38f;
|
||||
return true;
|
||||
}
|
||||
|
||||
float fx = (pos.x - this->m_liquidCorner.x) * 0.24f;
|
||||
float fy = (pos.y - this->m_liquidCorner.y) * 0.24f;
|
||||
|
||||
C2iVector tile;
|
||||
tile.x = static_cast<int32_t>(floor(fx));
|
||||
tile.y = static_cast<int32_t>(floor(fy));
|
||||
|
||||
if (tile.x < 0 || tile.y < 0 || !(tile < this->m_liquidTiles)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this->m_liquidTileList[tile.y * this->m_liquidTiles.x + tile.x].m_flags & 0xF) == 0xF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float dx = fx - tile.x;
|
||||
float dy = fy - tile.y;
|
||||
int32_t v0 = tile.y * this->m_liquidVerts.x + tile.x;
|
||||
int32_t v1 = this->m_liquidVerts.x + v0;
|
||||
float offset = (g_liquidTypeDB.GetRecord(type)->m_flags & 0x4) ? 0.0099999998f : 0.0f;
|
||||
|
||||
const SMOLiquidVert* verts = this->m_liquidVertexList;
|
||||
float h0 = verts[v0].m_waterVert.m_height;
|
||||
float top = h0 + (verts[v0 + 1].m_waterVert.m_height - h0) * dx;
|
||||
float h2 = verts[v1].m_waterVert.m_height;
|
||||
float bottom = h2 + (verts[v1 + 1].m_waterVert.m_height - h2) * dx;
|
||||
float height = top + (bottom - top) * dy;
|
||||
|
||||
if (offset + height <= pos.z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*level = height;
|
||||
*liquidType = this->m_liquidType;
|
||||
return true;
|
||||
}
|
||||
|
||||
// VERIFY: 0f477396 auto
|
||||
// OFFSET: 0x007C8BF0
|
||||
uint32_t CMapObjGroup::GetNumSharedTiles() {
|
||||
if (this->m_numSharedTiles > 0) {
|
||||
return this->m_numSharedTiles;
|
||||
}
|
||||
|
||||
int32_t count = 0;
|
||||
const SMOLTile* tile = this->m_liquidTileList;
|
||||
|
||||
for (int32_t y = 0; y < this->m_liquidTiles.y; y++) {
|
||||
for (int32_t x = 0; x < this->m_liquidTiles.x; x++) {
|
||||
if ((tile->m_flags & 0xF) != 0xF && (tile->m_flags & 0x80)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
tile++;
|
||||
}
|
||||
}
|
||||
|
||||
this->m_numSharedTiles = count;
|
||||
return count;
|
||||
}
|
||||
|
||||
// VERIFY: e95ab74c manual
|
||||
// OFFSET: 0x007C8C60
|
||||
void CMapObjGroup::GenLiquidVerts() {
|
||||
float x = this->m_liquidCorner.x;
|
||||
float y = this->m_liquidCorner.y;
|
||||
C3Vector* out = this->m_liquidVertArray->m_verts.m_data;
|
||||
const SMOLiquidVert* vert = this->m_liquidVertexList;
|
||||
|
||||
this->m_liquidHeight = vert->m_waterVert.m_height;
|
||||
this->m_liquidMaxHeight = vert->m_waterVert.m_height;
|
||||
|
||||
for (int32_t row = 0; row < this->m_liquidVerts.y; row++) {
|
||||
for (int32_t col = 0; col < this->m_liquidVerts.x; col++) {
|
||||
float height = vert->m_waterVert.m_height;
|
||||
out->x = x;
|
||||
out->y = y;
|
||||
out->z = height;
|
||||
out++;
|
||||
|
||||
this->m_liquidHeight = height <= this->m_liquidHeight ? height : this->m_liquidHeight;
|
||||
this->m_liquidMaxHeight = height < this->m_liquidMaxHeight ? this->m_liquidMaxHeight : height;
|
||||
|
||||
vert++;
|
||||
x += 4.1666665f;
|
||||
}
|
||||
|
||||
x = this->m_liquidCorner.x;
|
||||
y += 4.1666665f;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 5304b11e auto
|
||||
// OFFSET: 0x007CBDC0
|
||||
void CMapObjGroup::AllocLiquidVB(EGxVertexBufferFormat format, uint32_t vertexCount, uint32_t indexCount, CGxBatch** batch) {
|
||||
if (!this->m_liquidVertsBlock) {
|
||||
CMapObjGroup::vertexVBList.AllocVBB(&this->m_liquidVertsBlock, GxVertexSize(format), vertexCount);
|
||||
this->m_liquidVertsBlock->m_buffer->unk_001C = 0;
|
||||
}
|
||||
|
||||
if (!this->m_liquidIndicesBlock) {
|
||||
CMapObjGroup::indexVBList.AllocVBB(&this->m_liquidIndicesBlock, 2, indexCount);
|
||||
this->m_liquidIndicesBlock->m_buffer->unk_001C = 0;
|
||||
}
|
||||
|
||||
*batch = &this->m_liquidBatch;
|
||||
this->m_liquidVBRefCount++;
|
||||
}
|
||||
|
||||
// VERIFY: cd2471f5 auto
|
||||
// OFFSET: 0x007CBE30
|
||||
void CMapObjGroup::FreeLiquidVB() {
|
||||
if (!this->m_liquidVBRefCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (--this->m_liquidVBRefCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_liquidVertsBlock) {
|
||||
CMapObjGroup::vertexVBList.FreeVBB(this->m_liquidVertsBlock);
|
||||
}
|
||||
|
||||
if (this->m_liquidIndicesBlock) {
|
||||
CMapObjGroup::indexVBList.FreeVBB(this->m_liquidIndicesBlock);
|
||||
}
|
||||
|
||||
this->m_liquidVertsBlock = nullptr;
|
||||
this->m_liquidIndicesBlock = nullptr;
|
||||
}
|
||||
|
||||
// VERIFY: 0c68f770 auto
|
||||
// OFFSET: 0x007D7310
|
||||
int32_t CMapObjGroup::GetLiquidType(uint32_t groupLiquid) {
|
||||
if (groupLiquid < 21 && groupLiquid) {
|
||||
switch ((groupLiquid - 1) & 3) {
|
||||
case 0:
|
||||
return (this->m_flags & 0x80000) ? 14 : 13;
|
||||
|
||||
case 1:
|
||||
return 14;
|
||||
|
||||
case 2:
|
||||
return 19;
|
||||
|
||||
case 3:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
return groupLiquid;
|
||||
}
|
||||
|
||||
// VERIFY: c9184804 manual
|
||||
// OFFSET: 0x007C9110
|
||||
void CMapObjGroup::VectorIntersectLiquidSX(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles) {
|
||||
int32_t x = CMath::fint_(start.x - 0.5f);
|
||||
int32_t y = CMath::fint_(start.y - 0.5f);
|
||||
int32_t endX = CMath::fint_(end.x - 0.5f);
|
||||
int32_t step = endX >= x ? 1 : -1;
|
||||
endX += step;
|
||||
|
||||
while (x != endX) {
|
||||
tiles[(*tileCount)++] = x;
|
||||
tiles[(*tileCount)++] = y;
|
||||
x += step;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 4f16d5fa manual
|
||||
// OFFSET: 0x007C91A0
|
||||
void CMapObjGroup::VectorIntersectLiquidSY(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles) {
|
||||
int32_t x = CMath::fint_(start.x - 0.5f);
|
||||
int32_t y = CMath::fint_(start.y - 0.5f);
|
||||
int32_t endY = CMath::fint_(end.y - 0.5f);
|
||||
int32_t step = endY >= y ? 1 : -1;
|
||||
endY += step;
|
||||
|
||||
while (y != endY) {
|
||||
tiles[(*tileCount)++] = x;
|
||||
tiles[(*tileCount)++] = y;
|
||||
y += step;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: f3f15286 manual
|
||||
// OFFSET: 0x007C9230
|
||||
void CMapObjGroup::VectorIntersectLiquidDX(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles) {
|
||||
int32_t x = CMath::fint_(start.x - 0.5f);
|
||||
int32_t y = CMath::fint_(start.y - 0.5f);
|
||||
int32_t step;
|
||||
float frac;
|
||||
|
||||
if (start.x > end.x) {
|
||||
step = -1;
|
||||
frac = static_cast<float>(x + 1) - start.x;
|
||||
} else {
|
||||
step = 1;
|
||||
frac = start.x - static_cast<float>(x);
|
||||
}
|
||||
|
||||
float slope = (end.y - start.y) / fabs(end.x - start.x);
|
||||
float startY = start.y - frac * slope;
|
||||
float offset = 0.0f;
|
||||
int32_t endX = CMath::fint_(end.x - 0.5f) + step;
|
||||
|
||||
if (x == endX) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t prevY = y;
|
||||
int32_t curY = y;
|
||||
|
||||
do {
|
||||
if (curY != prevY) {
|
||||
tiles[(*tileCount)++] = x;
|
||||
tiles[(*tileCount)++] = prevY;
|
||||
}
|
||||
|
||||
offset += slope;
|
||||
tiles[(*tileCount)++] = x;
|
||||
tiles[(*tileCount)++] = curY;
|
||||
x += step;
|
||||
prevY = curY;
|
||||
curY = CMath::fint_(offset + startY - 0.5f);
|
||||
} while (x != endX);
|
||||
|
||||
if (curY != prevY && curY >= 0 && curY < this->m_liquidTiles.y) {
|
||||
tiles[(*tileCount)++] = x - step;
|
||||
tiles[(*tileCount)++] = curY;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 3612548b manual
|
||||
// OFFSET: 0x007C9370
|
||||
void CMapObjGroup::VectorIntersectLiquidDY(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles) {
|
||||
int32_t x = CMath::fint_(start.x - 0.5f);
|
||||
int32_t y = CMath::fint_(start.y - 0.5f);
|
||||
int32_t step;
|
||||
float frac;
|
||||
|
||||
if (start.y > end.y) {
|
||||
step = -1;
|
||||
frac = static_cast<float>(y + 1) - start.y;
|
||||
} else {
|
||||
step = 1;
|
||||
frac = start.y - static_cast<float>(y);
|
||||
}
|
||||
|
||||
float slope = (end.x - start.x) / fabs(end.y - start.y);
|
||||
float startX = start.x - frac * slope;
|
||||
float offset = 0.0f;
|
||||
int32_t endY = CMath::fint_(end.y - 0.5f) + step;
|
||||
|
||||
if (y == endY) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t prevX = x;
|
||||
int32_t curX = x;
|
||||
|
||||
do {
|
||||
if (curX != prevX) {
|
||||
tiles[(*tileCount)++] = prevX;
|
||||
tiles[(*tileCount)++] = y;
|
||||
}
|
||||
|
||||
offset += slope;
|
||||
tiles[(*tileCount)++] = curX;
|
||||
tiles[(*tileCount)++] = y;
|
||||
y += step;
|
||||
prevX = curX;
|
||||
curX = CMath::fint_(offset + startX - 0.5f);
|
||||
} while (y != endY);
|
||||
|
||||
if (curX != prevX && curX >= 0 && curX < this->m_liquidTiles.x) {
|
||||
tiles[(*tileCount)++] = curX;
|
||||
tiles[(*tileCount)++] = y - step;
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 8f1675f7 manual
|
||||
// OFFSET: 0x007C8DD0
|
||||
bool CMapObjGroup::VectorIntersectLiquidTiles(const C3Segment& seg, float* t, uint32_t flags, uint32_t* tileCount, uint8_t* tiles, World::TriData* triData, CMapObjDef* mapObjDef) {
|
||||
int32_t type = this->m_liquidType;
|
||||
|
||||
if (!type || !this->m_liquidTiles.x || !this->m_liquidTiles.y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & 0x10000) && !(flags & 0x20000) && !(g_liquidTypeDB.GetRecord(type)->m_flags & 0x4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float dx = seg.t.x - seg.b.x;
|
||||
float dy = seg.t.y - seg.b.y;
|
||||
float dz = seg.t.z - seg.b.z;
|
||||
float invLength = 1.0f / sqrt(dx * dx + dz * dz + dy * dy);
|
||||
|
||||
C3Ray ray;
|
||||
ray.origin = seg.b;
|
||||
ray.dir.x = dx * invLength;
|
||||
ray.dir.y = dy * invLength;
|
||||
ray.dir.z = invLength * dz;
|
||||
|
||||
C3Vector* verts = this->m_liquidVertArray->m_verts.m_data;
|
||||
uint32_t tris[2][3];
|
||||
tris[0][0] = 0;
|
||||
tris[0][1] = this->m_liquidVerts.x + 1;
|
||||
tris[0][2] = this->m_liquidVerts.x;
|
||||
tris[1][0] = 0;
|
||||
tris[1][1] = 1;
|
||||
tris[1][2] = this->m_liquidVerts.x + 1;
|
||||
|
||||
World::TriData::Batch* batch = nullptr;
|
||||
uint16_t* indices = nullptr;
|
||||
bool found = false;
|
||||
|
||||
for (uint32_t i = 0; i < *tileCount; i += 2) {
|
||||
uint32_t tileX = tiles[0];
|
||||
uint32_t tileY = tiles[1];
|
||||
|
||||
if ((this->m_liquidTileList[tileY * this->m_liquidTiles.x + tileX].m_flags & 0xF) != 0xF) {
|
||||
uint32_t base = tileX + tileY * this->m_liquidVerts.x;
|
||||
|
||||
for (uint32_t j = 0; j < 2; j++) {
|
||||
uint32_t triIndices[3];
|
||||
triIndices[0] = base + tris[j][0];
|
||||
triIndices[1] = base + tris[j][1];
|
||||
triIndices[2] = base + tris[j][2];
|
||||
|
||||
float hitT = 1.0f;
|
||||
|
||||
if (!NTempest::Intersect(ray, verts, triIndices, &hitT, nullptr, 0.0099999998f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hitT *= invLength;
|
||||
|
||||
if (hitT >= *t || hitT < 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*t = hitT;
|
||||
|
||||
if (!triData) {
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
batch = triData->AllocBatch();
|
||||
|
||||
if (batch) {
|
||||
batch->m_def = mapObjDef;
|
||||
batch->m_matrix = &mapObjDef->m_mat;
|
||||
batch->m_vertexList = this->m_liquidVertArray->m_verts.m_data;
|
||||
indices = triData->AllocIndices(3);
|
||||
batch->m_indices = indices;
|
||||
}
|
||||
}
|
||||
|
||||
found = true;
|
||||
|
||||
if (!batch || !batch->m_indices) {
|
||||
continue;
|
||||
}
|
||||
|
||||
batch->m_indexCount = 0;
|
||||
|
||||
for (uint32_t k = 0; k < 3; k++) {
|
||||
uint16_t index = base + tris[j][k];
|
||||
indices[batch->m_indexCount++] = index;
|
||||
batch->m_minVertexIndex = batch->m_minVertexIndex < index ? batch->m_minVertexIndex : index;
|
||||
batch->m_maxVertexIndex = batch->m_maxVertexIndex > index ? batch->m_maxVertexIndex : index;
|
||||
}
|
||||
|
||||
batch->m_faceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
tiles += 2;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
// VERIFY: 4c425802 auto
|
||||
// OFFSET: 0x007C9DD0
|
||||
bool CMapObjGroup::VectorIntersectLiquid(const C3Segment& seg, float* t, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef) {
|
||||
float sizeY = this->m_liquidTiles.y * 4.1666665f - 0.1f;
|
||||
sizeY = sizeY > 0.0f ? sizeY : 0.0f;
|
||||
float sizeX = 4.1666665f * this->m_liquidTiles.x - 0.1f;
|
||||
sizeX = sizeX > 0.0f ? sizeX : 0.0f;
|
||||
|
||||
CAaBox box;
|
||||
box.b.x = this->m_liquidCorner.x;
|
||||
box.b.y = this->m_liquidCorner.y;
|
||||
box.b.z = this->m_liquidHeight;
|
||||
box.t.x = sizeX + this->m_liquidCorner.x;
|
||||
box.t.y = sizeY + this->m_liquidCorner.y;
|
||||
box.t.z = this->m_liquidMaxHeight;
|
||||
|
||||
C3Vector start = seg.b;
|
||||
C3Vector end = seg.t;
|
||||
C3Vector dir;
|
||||
dir.x = end.x - start.x;
|
||||
dir.y = end.y - start.y;
|
||||
dir.z = end.z - start.z;
|
||||
|
||||
float lengthSq = dir.z * dir.z + dir.y * dir.y + dir.x * dir.x;
|
||||
|
||||
if (lengthSq > 2.3841858e-7f) {
|
||||
float invLength = 1.0f / sqrt(lengthSq);
|
||||
dir.x *= invLength;
|
||||
dir.y *= invLength;
|
||||
dir.z *= invLength;
|
||||
}
|
||||
|
||||
if (!box.ContainsPoint(start)) {
|
||||
C3Ray ray;
|
||||
ray.origin = seg.b;
|
||||
ray.dir = dir;
|
||||
float rayT = 1.0f;
|
||||
|
||||
if (!NTempest::Intersect(ray, box, &rayT, &start)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!box.ContainsPoint(end)) {
|
||||
C3Ray ray;
|
||||
ray.origin = end;
|
||||
dir.x = -dir.x;
|
||||
dir.y = -dir.y;
|
||||
dir.z = -dir.z;
|
||||
ray.dir = dir;
|
||||
float rayT = 1.0f;
|
||||
|
||||
if (!NTempest::Intersect(ray, box, &rayT, &end)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t tileCount = 0;
|
||||
uint8_t tiles[0x800];
|
||||
|
||||
start.x = (start.x - this->m_liquidCorner.x) * 0.24f;
|
||||
start.y = (start.y - this->m_liquidCorner.y) * 0.24f;
|
||||
start.z = start.z * 0.24f;
|
||||
end.x = (end.x - this->m_liquidCorner.x) * 0.24f;
|
||||
end.y = (end.y - this->m_liquidCorner.y) * 0.24f;
|
||||
end.z = 0.24f * end.z;
|
||||
|
||||
float deltaX = end.x - start.x;
|
||||
float deltaY = fabs(end.y - start.y);
|
||||
|
||||
if (deltaY < 2.3841858e-7f) {
|
||||
this->VectorIntersectLiquidSX(start, end, &tileCount, tiles, sizeof(tiles));
|
||||
} else if (fabs(deltaX) < 2.3841858e-7f) {
|
||||
this->VectorIntersectLiquidSY(start, end, &tileCount, tiles, sizeof(tiles));
|
||||
} else if (deltaY >= fabs(deltaX)) {
|
||||
this->VectorIntersectLiquidDY(start, end, &tileCount, tiles, sizeof(tiles));
|
||||
} else {
|
||||
this->VectorIntersectLiquidDX(start, end, &tileCount, tiles, sizeof(tiles));
|
||||
}
|
||||
|
||||
return this->VectorIntersectLiquidTiles(seg, t, flags, &tileCount, tiles, triData, mapObjDef);
|
||||
}
|
||||
|
||||
// VERIFY: 2533e68d manual
|
||||
// OFFSET: 0x007C94B0
|
||||
bool CMapObjGroup::GetLiquidTris(const CAaBox& box, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef) {
|
||||
int32_t type = this->m_liquidType;
|
||||
|
||||
if (!type || !this->m_liquidTiles.x || !this->m_liquidTiles.y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & 0x10000) && !(flags & 0x20000) && !(g_liquidTypeDB.GetRecord(type)->m_flags & 0x4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
C3Vector points[2];
|
||||
points[0].x = box.b.x - this->m_liquidCorner.x;
|
||||
points[0].y = box.b.y - this->m_liquidCorner.y;
|
||||
points[0].z = box.b.z;
|
||||
points[1].x = box.t.x - this->m_liquidCorner.x;
|
||||
points[1].y = box.t.y - this->m_liquidCorner.y;
|
||||
points[1].z = box.t.z;
|
||||
|
||||
CAaBox bounds = CAaBox::Bounding(points, 2);
|
||||
|
||||
CiRect rect;
|
||||
rect.maxX = static_cast<int32_t>(floor(bounds.t.x * 0.24f));
|
||||
rect.maxY = static_cast<int32_t>(floor(bounds.t.y * 0.24f));
|
||||
rect.minY = static_cast<int32_t>(floor(bounds.b.y * 0.24f));
|
||||
rect.minX = static_cast<int32_t>(floor(bounds.b.x * 0.24f));
|
||||
|
||||
if (rect.maxX < 0 || rect.maxY < 0 || rect.minX >= this->m_liquidTiles.x || rect.minY >= this->m_liquidTiles.y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CiRect clip;
|
||||
clip.minY = 0;
|
||||
clip.minX = 0;
|
||||
clip.maxY = this->m_liquidTiles.y - 1;
|
||||
clip.maxX = this->m_liquidTiles.x - 1;
|
||||
rect &= clip;
|
||||
|
||||
int32_t vertSkip = this->m_liquidVerts.x - rect.maxX + rect.minX - 2;
|
||||
int32_t height = rect.maxY - rect.minY;
|
||||
int32_t width = rect.maxX - rect.minX;
|
||||
uint32_t cullSize = (width + 2) * (height + 2);
|
||||
int32_t first = rect.minX + rect.minY * this->m_liquidVerts.x;
|
||||
|
||||
if (cullSize > 0x2000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* cull = static_cast<uint8_t*>(alloca(cullSize));
|
||||
const C3Vector* vert = this->m_liquidVertArray->m_verts.m_data + first;
|
||||
uint8_t* cullOut = cull;
|
||||
|
||||
for (int32_t y = rect.minY; y <= rect.maxY + 1; y++) {
|
||||
for (int32_t x = rect.minX; x <= rect.maxX + 1; x++) {
|
||||
*cullOut++ = CullLiquidVertexZ(box, *vert);
|
||||
vert++;
|
||||
}
|
||||
|
||||
vert += vertSkip;
|
||||
}
|
||||
|
||||
const C3Vector* tileVert = this->m_liquidVertArray->m_verts.m_data + first;
|
||||
const SMOLTile* tile = &this->m_liquidTileList[rect.minY * this->m_liquidTiles.x + rect.minX];
|
||||
int32_t tileSkip = this->m_liquidTiles.x - rect.maxX + rect.minX - 1;
|
||||
|
||||
int32_t cullTris[2][3];
|
||||
cullTris[0][0] = 0;
|
||||
cullTris[0][1] = width + 3;
|
||||
cullTris[0][2] = width + 2;
|
||||
cullTris[1][0] = 0;
|
||||
cullTris[1][1] = 1;
|
||||
cullTris[1][2] = width + 3;
|
||||
|
||||
int32_t vertTris[2][3];
|
||||
vertTris[0][0] = 0;
|
||||
vertTris[0][1] = this->m_liquidVerts.x + 1;
|
||||
vertTris[0][2] = this->m_liquidVerts.x;
|
||||
vertTris[1][0] = 0;
|
||||
vertTris[1][1] = 1;
|
||||
vertTris[1][2] = this->m_liquidVerts.x + 1;
|
||||
|
||||
World::TriData::Batch* batch = nullptr;
|
||||
uint16_t* indices = nullptr;
|
||||
bool found = false;
|
||||
const uint8_t* cullTile = cull;
|
||||
|
||||
for (int32_t y = rect.minY; y <= rect.maxY; y++) {
|
||||
for (int32_t x = rect.minX; x <= rect.maxX; x++) {
|
||||
if ((tile->m_flags & 0xF) != 0xF) {
|
||||
for (uint32_t j = 0; j < 2; j++) {
|
||||
if (cullTile[cullTris[j][0]] & cullTile[cullTris[j][2]] & cullTile[cullTris[j][1]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
batch = triData->AllocBatch();
|
||||
|
||||
if (batch) {
|
||||
batch->m_def = mapObjDef;
|
||||
batch->m_matrix = &mapObjDef->m_mat;
|
||||
batch->m_vertexList = this->m_liquidVertArray->m_verts.m_data;
|
||||
indices = triData->AllocIndices(6 * (width + 1) * (height + 1));
|
||||
batch->m_indices = indices;
|
||||
}
|
||||
}
|
||||
|
||||
found = true;
|
||||
|
||||
if (!batch || !batch->m_indices) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32_t k = 0; k < 3; k++) {
|
||||
uint16_t index = (tileVert - this->m_liquidVertArray->m_verts.m_data) + vertTris[j][k];
|
||||
indices[batch->m_indexCount++] = index;
|
||||
batch->m_minVertexIndex = batch->m_minVertexIndex < index ? batch->m_minVertexIndex : index;
|
||||
batch->m_maxVertexIndex = batch->m_maxVertexIndex > index ? batch->m_maxVertexIndex : index;
|
||||
}
|
||||
|
||||
batch->m_faceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
tileVert++;
|
||||
tile++;
|
||||
cullTile++;
|
||||
}
|
||||
|
||||
tileVert += tileSkip + 1;
|
||||
tile += tileSkip;
|
||||
cullTile++;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
// VERIFY: 22aa2402 manual
|
||||
// OFFSET: 0x007CAB70
|
||||
bool CMapObjGroup::GetLiquidTris(CFrustum& frustum, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef) {
|
||||
int32_t type = this->m_liquidType;
|
||||
|
||||
if (!type || !this->m_liquidTiles.x || !this->m_liquidTiles.y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & 0x10000) && !(flags & 0x20000) && !(g_liquidTypeDB.GetRecord(type)->m_flags & 0x4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
C3Vector offset;
|
||||
offset.x = -this->m_liquidCorner.x;
|
||||
offset.y = -this->m_liquidCorner.y;
|
||||
offset.z = -this->m_liquidCorner.z;
|
||||
|
||||
CWFrustum localFrustum;
|
||||
static_cast<CFrustum&>(localFrustum) = frustum;
|
||||
localFrustum.Translate(offset);
|
||||
|
||||
CAaBox bounds = CAaBox::Bounding(localFrustum.corners, 8);
|
||||
|
||||
CiRect rect;
|
||||
rect.maxX = static_cast<int32_t>(floor(bounds.t.x * 0.24f));
|
||||
rect.maxY = static_cast<int32_t>(floor(bounds.t.y * 0.24f));
|
||||
rect.minY = static_cast<int32_t>(floor(bounds.b.y * 0.24f));
|
||||
rect.minX = static_cast<int32_t>(floor(bounds.b.x * 0.24f));
|
||||
|
||||
if (rect.maxX < 0 || rect.maxY < 0 || rect.minX >= this->m_liquidTiles.x || rect.minY >= this->m_liquidTiles.y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CiRect clip;
|
||||
clip.minY = 0;
|
||||
clip.minX = 0;
|
||||
clip.maxY = this->m_liquidTiles.y - 1;
|
||||
clip.maxX = this->m_liquidTiles.x - 1;
|
||||
rect &= clip;
|
||||
|
||||
int32_t vertSkip = this->m_liquidVerts.x - rect.maxX + rect.minX - 2;
|
||||
int32_t height = rect.maxY - rect.minY;
|
||||
int32_t width = rect.maxX - rect.minX;
|
||||
uint32_t cullSize = (width + 2) * (height + 2);
|
||||
int32_t first = rect.minX + rect.minY * this->m_liquidVerts.x;
|
||||
|
||||
if (cullSize > 0x2000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* cull = static_cast<uint8_t*>(alloca(cullSize));
|
||||
const C3Vector* vert = this->m_liquidVertArray->m_verts.m_data + first;
|
||||
uint8_t* cullOut = cull;
|
||||
|
||||
for (int32_t y = rect.minY; y <= rect.maxY + 1; y++) {
|
||||
for (int32_t x = rect.minX; x <= rect.maxX + 1; x++) {
|
||||
frustum.Cull(*vert, *cullOut);
|
||||
vert++;
|
||||
cullOut++;
|
||||
}
|
||||
|
||||
vert += vertSkip;
|
||||
}
|
||||
|
||||
const C3Vector* tileVert = this->m_liquidVertArray->m_verts.m_data + first;
|
||||
const SMOLTile* tile = &this->m_liquidTileList[rect.minY * this->m_liquidTiles.x + rect.minX];
|
||||
int32_t tileSkip = this->m_liquidTiles.x - rect.maxX + rect.minX - 1;
|
||||
|
||||
int32_t cullTris[2][3];
|
||||
cullTris[0][0] = 0;
|
||||
cullTris[0][1] = width + 3;
|
||||
cullTris[0][2] = width + 2;
|
||||
cullTris[1][0] = 0;
|
||||
cullTris[1][1] = 1;
|
||||
cullTris[1][2] = width + 3;
|
||||
|
||||
int32_t vertTris[2][3];
|
||||
vertTris[0][0] = 0;
|
||||
vertTris[0][1] = this->m_liquidVerts.x + 1;
|
||||
vertTris[0][2] = this->m_liquidVerts.x;
|
||||
vertTris[1][0] = 0;
|
||||
vertTris[1][1] = 1;
|
||||
vertTris[1][2] = this->m_liquidVerts.x + 1;
|
||||
|
||||
World::TriData::Batch* batch = nullptr;
|
||||
uint16_t* indices = nullptr;
|
||||
bool found = false;
|
||||
const uint8_t* cullTile = cull;
|
||||
|
||||
for (int32_t y = rect.minY; y <= rect.maxY; y++) {
|
||||
for (int32_t x = rect.minX; x <= rect.maxX; x++) {
|
||||
if ((tile->m_flags & 0xF) != 0xF) {
|
||||
for (uint32_t j = 0; j < 2; j++) {
|
||||
if (cullTile[cullTris[j][0]] & cullTile[cullTris[j][2]] & cullTile[cullTris[j][1]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
batch = triData->AllocBatch();
|
||||
|
||||
if (batch) {
|
||||
batch->m_def = mapObjDef;
|
||||
batch->m_matrix = &mapObjDef->m_mat;
|
||||
batch->m_vertexList = this->m_liquidVertArray->m_verts.m_data;
|
||||
indices = triData->AllocIndices(6 * (width + 1) * (height + 1));
|
||||
batch->m_indices = indices;
|
||||
}
|
||||
}
|
||||
|
||||
found = true;
|
||||
|
||||
if (!batch || !batch->m_indices) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32_t k = 0; k < 3; k++) {
|
||||
uint16_t index = (tileVert - this->m_liquidVertArray->m_verts.m_data) + vertTris[j][k];
|
||||
indices[batch->m_indexCount++] = index;
|
||||
batch->m_minVertexIndex = batch->m_minVertexIndex < index ? batch->m_minVertexIndex : index;
|
||||
batch->m_maxVertexIndex = batch->m_maxVertexIndex > index ? batch->m_maxVertexIndex : index;
|
||||
}
|
||||
|
||||
batch->m_faceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
tileVert++;
|
||||
tile++;
|
||||
cullTile++;
|
||||
}
|
||||
|
||||
tileVert += tileSkip + 1;
|
||||
tile += tileSkip;
|
||||
cullTile++;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
// VERIFY: 121a8eb8 manual
|
||||
// OFFSET: 0x007CA110
|
||||
bool CMapObjGroup::GetLiquidFacets(const CAaBox& box, uint32_t flags, World::FacetData* facets, CMapObjDef* mapObjDef) {
|
||||
World::TriData::statusFlags = 0;
|
||||
World::TriData::nBatches = 0;
|
||||
World::TriData::faceIndexCursor = 0;
|
||||
World::TriData::indexCursor = 0;
|
||||
World::TriData::unk_CB7538 = 0;
|
||||
|
||||
World::TriData triData;
|
||||
this->GetLiquidTris(box, flags, &triData, mapObjDef);
|
||||
|
||||
WGUID guid;
|
||||
guid.m_guidLow = mapObjDef->unk_0148;
|
||||
guid.m_guidHigh = mapObjDef->unk_014C;
|
||||
World::TriDataToFacetData(&triData, facets, guid);
|
||||
|
||||
return World::TriData::nBatches != 0;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "WoW/Common/AaBsp.h"
|
||||
#include "Engine/Source/Tempest/C2iVector.h"
|
||||
|
||||
class CFrustum;
|
||||
struct SIffChunk;
|
||||
|
||||
struct BspQuery_Segment;
|
||||
class C2Vector;
|
||||
class C3Vector;
|
||||
@@ -28,12 +31,17 @@ class CMapObjDef;
|
||||
class CMapObjGroup;
|
||||
struct SMOBatch;
|
||||
struct SMOLTile;
|
||||
struct SMOLiquidVert;
|
||||
union SMOLiquidVert;
|
||||
struct SMOMaterial;
|
||||
struct SMOPoly;
|
||||
class VBBList;
|
||||
class VBBList_Block;
|
||||
|
||||
namespace World {
|
||||
class FacetData;
|
||||
class TriData;
|
||||
}
|
||||
|
||||
struct BspQuery {
|
||||
/* 0000 */ int32_t* m_overflowFlags;
|
||||
/* 0004 */ SMOPoly* m_faces;
|
||||
@@ -89,6 +97,7 @@ class CMapObjGroup {
|
||||
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static void AsyncPostloadCallback(void* arg);
|
||||
|
||||
/* 0000 */ int32_t m_objectIndex;
|
||||
/* 0004 */ VBBList_Block* m_vertsBlock;
|
||||
@@ -97,11 +106,8 @@ class CMapObjGroup {
|
||||
/* 0010 */ VBBList_Block* m_liquidVertsBlock;
|
||||
/* 0014 */ VBBList_Block* m_liquidIndicesBlock;
|
||||
/* 0018 */ float m_timer;
|
||||
/* 001C */ void* unk_001C;
|
||||
/* 0020 */ int32_t unk_0020;
|
||||
/* 0024 */ int32_t unk_0024;
|
||||
/* 0028 */ int32_t unk_0028;
|
||||
/* 002C */ int16_t unk_002C [2];
|
||||
/* 001C */ CMapObjGroup::VertArray* m_liquidVertArray;
|
||||
/* 0020 */ CGxBatch m_liquidBatch;
|
||||
/* 0030 */ int32_t m_flags;
|
||||
/* 0034 */ CAaBox m_bbox;
|
||||
/* 004C */ float m_distToCamera;
|
||||
@@ -130,7 +136,7 @@ class CMapObjGroup {
|
||||
/* 0104 */ uint16_t* m_doodadRefList;
|
||||
/* 0108 */ CImVector* m_colorVertexList;
|
||||
/* 010C */ CImVector* m_colorVertexListExtra;
|
||||
/* 0110 */ int32_t unk_0110;
|
||||
/* 0110 */ int32_t m_liquidVBRefCount;
|
||||
/* 0114 */ C2iVector m_liquidVerts;
|
||||
/* 011C */ C2iVector m_liquidTiles;
|
||||
/* 0124 */ C3Vector m_liquidCorner;
|
||||
@@ -138,9 +144,9 @@ class CMapObjGroup {
|
||||
/* 0134 */ SMOLiquidVert* m_liquidVertexList;
|
||||
/* 0138 */ SMOLTile* m_liquidTileList;
|
||||
/* 013C */ float m_liquidHeight;
|
||||
/* 0140 */ int32_t unk_0140;
|
||||
/* 0140 */ float m_liquidMaxHeight;
|
||||
/* 0144 */ int32_t m_liquidType;
|
||||
/* 0148 */ int32_t m_unkFlag;
|
||||
/* 0148 */ int32_t m_numSharedTiles;
|
||||
/* 014C */ int32_t unk_014C;
|
||||
/* 0150 */ int32_t m_polyListSize;
|
||||
/* 0154 */ int32_t m_indicesCount;
|
||||
@@ -160,7 +166,8 @@ class CMapObjGroup {
|
||||
/* 018C */ CMapObj* m_parent;
|
||||
/* 0190 */ int32_t unk_0190;
|
||||
/* 0194 */ CAsyncObject* m_asyncObjPtr;
|
||||
/* 0198 */ int32_t m_unkLoadedFlag;
|
||||
/* 0198 */ int8_t m_unkLoadedFlag;
|
||||
/* 0199 */ uint8_t unk_0199[3];
|
||||
/* 019C */ int32_t m_unkIndexMin1;
|
||||
/* 01A0 */ int32_t m_unkIndexMax1;
|
||||
/* 01A4 */ uint16_t m_unkIndexMin2;
|
||||
@@ -168,8 +175,39 @@ class CMapObjGroup {
|
||||
/* 01A8 */ int32_t m_tSExplicitListMLinkoffset;
|
||||
/* 01AC */ void* m_tSExplicitListPtr;
|
||||
/* 01B0 */ void* m_tSExplicitListPtr2;
|
||||
/* 01B4 */ CMapObjGroup* m_perv;
|
||||
/* 01B8 */ CMapObjGroup* m_next;
|
||||
/* 01B4 */ TSLink<CMapObjGroup> m_asyncLoadLink;
|
||||
|
||||
CMapObjGroup();
|
||||
void Create();
|
||||
void CreateDataPointers(SIffChunk* dataChunk);
|
||||
void CreateOptionalDataPointers(SIffChunk* dataChunk);
|
||||
void AllocVB();
|
||||
void AllocLiquidVB(EGxVertexBufferFormat format, uint32_t vertexCount, uint32_t indexCount, CGxBatch** batch);
|
||||
void FreeLiquidVB();
|
||||
void SetIndexVB();
|
||||
void UploadIndexBuffer(CGxBuf* buf);
|
||||
void SetVertexVB();
|
||||
void FillVertexVB(CGxBuf* buf, EGxVertexBufferFormat format);
|
||||
void FixColorVertexAlpha();
|
||||
bool GetTris(CFrustum* frustum, uint32_t flags, uint16_t faceIgnoreFlags, uint32_t a5, CMapObjDef* mapObjDef);
|
||||
void GetTrisFromQuery(uint32_t a2, BspQuery* a3, CMapObjDef* mapObjDef, uint32_t a5);
|
||||
void SetLighting(uint32_t mode);
|
||||
bool Intersect(C3Segment& seg, float* dist, uint32_t flags, uint16_t faceIgnoreFlags, int32_t* hitIndex);
|
||||
bool GetFacesForLinking(C3Segment& seg, float* t0, int32_t* face0, float* t1, int32_t* face1);
|
||||
bool QueryLiquid(const C3Vector& pos, int32_t* liquidType, float* level);
|
||||
void QueryLiquidSounds(const C3Vector& pos, uint32_t* results);
|
||||
void GenLiquidVerts();
|
||||
int32_t GetLiquidType(uint32_t groupLiquid);
|
||||
uint32_t GetNumSharedTiles();
|
||||
bool GetLiquidTris(const CAaBox& box, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef);
|
||||
bool GetLiquidTris(CFrustum& frustum, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef);
|
||||
bool GetLiquidFacets(const CAaBox& box, uint32_t flags, World::FacetData* facets, CMapObjDef* mapObjDef);
|
||||
bool VectorIntersectLiquid(const C3Segment& seg, float* t, uint32_t flags, World::TriData* triData, CMapObjDef* mapObjDef);
|
||||
bool VectorIntersectLiquidTiles(const C3Segment& seg, float* t, uint32_t flags, uint32_t* tileCount, uint8_t* tiles, World::TriData* triData, CMapObjDef* mapObjDef);
|
||||
void VectorIntersectLiquidSX(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles);
|
||||
void VectorIntersectLiquidSY(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles);
|
||||
void VectorIntersectLiquidDX(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles);
|
||||
void VectorIntersectLiquidDY(const C3Vector& start, const C3Vector& end, uint32_t* tileCount, uint8_t* tiles, uint32_t maxTiles);
|
||||
};
|
||||
|
||||
struct SMOGroupHeader {
|
||||
@@ -193,10 +231,6 @@ struct SMOLTile {
|
||||
/* 0000 */ uint8_t m_flags;
|
||||
};
|
||||
|
||||
struct SMOLiquidVert {
|
||||
/* 0000 */ uint8_t unk_0000[8];
|
||||
};
|
||||
|
||||
struct SMOMVert {
|
||||
/* 0000 */ int16_t m_s;
|
||||
/* 0002 */ int16_t m_t;
|
||||
@@ -211,6 +245,11 @@ struct SMOWVert {
|
||||
/* 0004 */ float m_height;
|
||||
};
|
||||
|
||||
union SMOLiquidVert {
|
||||
/* 0000 */ SMOWVert m_waterVert;
|
||||
/* 0000 */ SMOMVert m_magmaVert;
|
||||
};
|
||||
|
||||
class VBBList_Block {
|
||||
public:
|
||||
/* 0000 */ TSLink<VBBList_Block> m_link;
|
||||
@@ -220,6 +259,8 @@ class VBBList_Block {
|
||||
/* 0014 */ CGxPool* m_pool;
|
||||
/* 0018 */ CGxBuf* m_buffer;
|
||||
/* 001C */ VBBList_Block* m_listHead;
|
||||
|
||||
void Set(uint32_t itemSize, uint32_t itemCount, uint32_t offset);
|
||||
};
|
||||
|
||||
class VBBList {
|
||||
@@ -232,24 +273,38 @@ class VBBList {
|
||||
/* 001C */ TSExplicitList<VBBList_Block, offsetof(VBBList_Block, m_link)> unk_001C;
|
||||
|
||||
void Destroy();
|
||||
VBBList_Block* AllocBlock();
|
||||
void AllocVBB(VBBList_Block** a1, uint32_t itemSize, uint32_t itemCount);
|
||||
void FreeVBB(VBBList_Block* block);
|
||||
void AssignBlock(VBBList_Block* a1, VBBList_Block** a2, uint32_t itemSize, uint32_t itemCount);
|
||||
};
|
||||
|
||||
namespace World {
|
||||
namespace TriData {
|
||||
struct Batch {
|
||||
/* 0000 */ C44Matrix* m_matrix;
|
||||
/* 0004 */ C3Vector* m_vertexList;
|
||||
/* 0008 */ C3Vector* m_normalList;
|
||||
/* 000C */ uint32_t unk_000C;
|
||||
/* 0010 */ uint16_t* m_indices;
|
||||
/* 0014 */ uint16_t* m_faceIndices;
|
||||
/* 0018 */ uint16_t m_indexCount;
|
||||
/* 001A */ uint16_t m_faceCount;
|
||||
/* 001C */ uint16_t m_minVertexIndex;
|
||||
/* 001E */ uint16_t m_maxVertexIndex;
|
||||
/* 0020 */ CMapObjDef* m_def;
|
||||
};
|
||||
}
|
||||
class TriData {
|
||||
public:
|
||||
struct Batch {
|
||||
/* 0000 */ C44Matrix* m_matrix;
|
||||
/* 0004 */ C3Vector* m_vertexList;
|
||||
/* 0008 */ C3Vector* m_normalList;
|
||||
/* 000C */ uint32_t unk_000C;
|
||||
/* 0010 */ uint16_t* m_indices;
|
||||
/* 0014 */ uint16_t* m_faceIndices;
|
||||
/* 0018 */ uint16_t m_indexCount;
|
||||
/* 001A */ uint16_t m_faceCount;
|
||||
/* 001C */ uint16_t m_minVertexIndex;
|
||||
/* 001E */ uint16_t m_maxVertexIndex;
|
||||
/* 0020 */ CMapObjDef* m_def;
|
||||
};
|
||||
|
||||
static uint32_t statusFlags;
|
||||
static uint32_t nBatches;
|
||||
static uint32_t faceIndexCursor;
|
||||
static uint32_t indexCursor;
|
||||
static uint32_t unk_CB7538;
|
||||
|
||||
Batch* AllocBatch();
|
||||
uint16_t* AllocIndices(uint32_t count);
|
||||
};
|
||||
}
|
||||
|
||||
class CAaBsp_Query_Segment {
|
||||
|
||||
@@ -1 +1,79 @@
|
||||
#include "MapObjRead.h"
|
||||
#include "Engine/Source/Services/AsyncFile.h"
|
||||
#include "Engine/Source/BlizzardCore/SFile2-Core.h"
|
||||
#include "WoW/Source/WorldClient/Map.h"
|
||||
#include "WoW/Source/WorldClient/MapObj.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
|
||||
// STATIC: 0x00ADFC4C
|
||||
TSList<CMapObj, TSGetExplicitLink<CMapObj> > CMapObj::s_asyncLoadQueue = TSExplicitList<CMapObj, offsetof(CMapObj, m_asyncLoadLink)>();
|
||||
|
||||
// STATIC: 0x00ADFC58
|
||||
TSList<CMapObjGroup, TSGetExplicitLink<CMapObjGroup> > CMapObj::s_unk_ADFC58 = TSExplicitList<CMapObjGroup, offsetof(CMapObjGroup, m_asyncLoadLink)>();
|
||||
|
||||
// VERIFY: 737e6a62 manual
|
||||
// OFFSET: 0x007D80C0
|
||||
bool CMapObj::Read(char* fileName) {
|
||||
SStrCopy(this->m_wmoName, fileName, STORM_MAX_STR);
|
||||
|
||||
SFileImpl* file = nullptr;
|
||||
|
||||
if (CMap::SafeOpen(fileName, &file)) {
|
||||
SStrCopy(this->m_wmoName, fileName, STORM_MAX_STR);
|
||||
} else {
|
||||
CMap::SafeOpen("world\\wmo\\Dungeon\\test\\missingwmo.wmo", &file);
|
||||
SStrCopy(this->m_wmoName, "world\\wmo\\Dungeon\\test\\missingwmo.wmo", STORM_MAX_STR);
|
||||
}
|
||||
|
||||
this->m_wmoFileSize = SFileGetFileSize(file, nullptr);
|
||||
this->m_pWmoData = SMemAlloc(this->m_wmoFileSize, __FILE__, __LINE__, 0);
|
||||
|
||||
this->m_asyncObject = AsyncFileReadAllocObject();
|
||||
this->m_asyncObject->m_file = file;
|
||||
this->m_asyncObject->m_userArg = this;
|
||||
this->m_asyncObject->m_buffer = this->m_pWmoData;
|
||||
this->m_asyncObject->m_size = this->m_wmoFileSize;
|
||||
this->m_asyncObject->m_userPostloadCallback = reinterpret_cast<void*>(CMapObj::PostloadCallback);
|
||||
this->m_asyncObject->m_priority = 124;
|
||||
AsyncFileReadObject(this->m_asyncObject, 0);
|
||||
|
||||
CMapObj::s_asyncLoadQueue.LinkToTail(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// VERIFY: d48a58f4 manual
|
||||
// OFFSET: 0x007D85E0
|
||||
void CMapObj::ReadGroup(uint32_t index, bool preLoad) {
|
||||
CMapObjGroup* group = this->m_mapObjGroupArray[index];
|
||||
|
||||
char fileName[256];
|
||||
strcpy(fileName, this->m_wmoName);
|
||||
SStrPrintf(strrchr(fileName, '.'), sizeof(fileName), "_%03d", index);
|
||||
strcat(fileName, ".wmo");
|
||||
|
||||
SFileImpl* file = nullptr;
|
||||
CMap::SafeOpen(fileName, &file);
|
||||
|
||||
group->m_fileSize = SFileGetFileSize(file, nullptr);
|
||||
group->m_filePtr = SMemAlloc(group->m_fileSize, __FILE__, __LINE__, 0);
|
||||
group->m_parent = this;
|
||||
|
||||
if (preLoad) {
|
||||
CMap::SafeRead(fileName, file, group->m_filePtr, group->m_fileSize);
|
||||
group->Create();
|
||||
SFileCloseFile(file);
|
||||
return;
|
||||
}
|
||||
|
||||
CAsyncObject* object = AsyncFileReadAllocObject();
|
||||
object->m_file = file;
|
||||
object->m_buffer = group->m_filePtr;
|
||||
object->m_size = group->m_fileSize;
|
||||
object->m_userArg = group;
|
||||
object->m_userPostloadCallback = reinterpret_cast<void*>(CMapObjGroup::AsyncPostloadCallback);
|
||||
group->m_asyncObjPtr = object;
|
||||
AsyncFileReadObject(object, 0);
|
||||
|
||||
CMapObj::s_unk_ADFC58.LinkToTail(group);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,15 @@
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Gx/CGxTex.h"
|
||||
#include "Engine/Source/Tempest/C44Matrix.h"
|
||||
#include "Engine/Source/Tempest/C4Vector.h"
|
||||
#include "Engine/Source/Tempest/CImVector.h"
|
||||
|
||||
class CMapArea;
|
||||
class CM2Lighting;
|
||||
class CGxShader;
|
||||
struct SMLayer;
|
||||
|
||||
struct CGxBuf;
|
||||
struct CGxPool;
|
||||
@@ -36,6 +45,7 @@ class CMapChunkBufBlock {
|
||||
/* 0044 */ TSLink<CMapChunkBufBlock> m_bufLink;
|
||||
|
||||
CMapChunkBufBlock();
|
||||
~CMapChunkBufBlock();
|
||||
};
|
||||
|
||||
class CMapRenderChunkLayer {
|
||||
@@ -44,12 +54,18 @@ class CMapRenderChunkLayer {
|
||||
/* 0002 */ int16_t m_layerIndex;
|
||||
/* 0004 */ CTexture* m_texture;
|
||||
/* 0008 */ int32_t m_textureId;
|
||||
/* 000C */ int32_t m_layerTexture;
|
||||
/* 000C */ CTexture* m_layerTexture;
|
||||
/* 0010 */ CMapRenderChunk* m_owner;
|
||||
|
||||
CMapRenderChunkLayer();
|
||||
};
|
||||
|
||||
class CMapRenderChunk {
|
||||
public:
|
||||
struct SLayerAlpha;
|
||||
struct SVertexShaderConstants;
|
||||
typedef void (*RenderLayersFunc)(CMapRenderChunk* renderChunk);
|
||||
|
||||
static int32_t s_bPoolsDirty;
|
||||
static EGxVertexBufferFormat s_gxBufVertexFormat;
|
||||
static uint32_t s_pnEstimateVertex;
|
||||
@@ -59,22 +75,64 @@ class CMapRenderChunk {
|
||||
static TSGrowableArray<CMapChunkBufBlock> s_chunkBlockArray;
|
||||
static TSExplicitList<CMapChunkBuf, offsetof(CMapChunkBuf, unk_0014)> s_renderChunkBufFreeList;
|
||||
static TSExplicitList<CMapChunkBufBlock, offsetof(CMapChunkBufBlock, m_blockLink)> s_chunkBufBlockFreeList;
|
||||
static TSExplicitList<CMapChunkBufBlock, offsetof(CMapChunkBufBlock, m_bufLink)> s_bufList;
|
||||
static CGxBatch unk_AEEC60;
|
||||
static uint32_t s_defaultTex[8192];
|
||||
static CGxShader* s_currentShader[4];
|
||||
static CGxShader* s_currentShaderX[4];
|
||||
static CGxShader* s_pixelShader[2];
|
||||
static RenderLayersFunc s_renderLayersFunc;
|
||||
static CImVector s_fogColor;
|
||||
static SVertexShaderConstants s_vertexShaderConsts;
|
||||
|
||||
static void Destroy();
|
||||
static void DestroyBufs();
|
||||
static void Initialize();
|
||||
static void SetDirty();
|
||||
|
||||
~CMapRenderChunk();
|
||||
static void UpdatePools();
|
||||
static void SetVertexFormat(EGxVertexBufferFormat format);
|
||||
static void PurgeChunkBufBlocks();
|
||||
static CMapChunkBuf* AllocBuf(int32_t a1, CMapRenderChunk* renderChunk);
|
||||
static CTexture* AllocTexture(uint32_t width, uint32_t height, void* userArg, GxTexUserFunc userFunc, EGxTexFormat format, EGxTexFormat dataFormat);
|
||||
static void UpdateShaderGxTexture(EGxTexCommand cmd, uint32_t w, uint32_t h, uint32_t d, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
static void UpdateLayerGxTexture(EGxTexCommand cmd, uint32_t w, uint32_t h, uint32_t d, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
static void UpdateShadowGxTexture(EGxTexCommand cmd, uint32_t w, uint32_t h, uint32_t d, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
|
||||
static void RenderMultiPassAlpha(CMapRenderChunk* renderChunk);
|
||||
static void RenderMultiPassAdditive(CMapRenderChunk* renderChunk);
|
||||
static void SetShaders(int32_t a1, int32_t a2);
|
||||
static void InitializeVertexShaderConstants(const C44Matrix& world, const C44Matrix& view);
|
||||
static CGxShader* GetVertexShader(int32_t pointLights, int32_t layers, int32_t specular, int32_t vertexColor, int32_t a5, int32_t shadow);
|
||||
static void ComputeTexMatrices(C44Matrix& layerMatrix, C44Matrix& alphaMatrix, const C3Vector& offset, float scale);
|
||||
static void RenderMultiPassPixelShaderBigAlpha(CMapRenderChunk* renderChunk);
|
||||
static void RenderMultiPassPixelShader(CMapRenderChunk* renderChunk);
|
||||
static void RenderMultiPassVertexPixelShaderBigAlpha(CMapRenderChunk* renderChunk);
|
||||
static void RenderMultiPassVertexPixelShader(CMapRenderChunk* renderChunk);
|
||||
static void SetVertexShader(CMapRenderChunk* renderChunk, int32_t layerCount, int32_t a3);
|
||||
static uint8_t* DecodeAlphaRLE(uint8_t* src, uint8_t* dst, int32_t count);
|
||||
static void SetupAlphaRows(uint8_t** shadowCursor, uint8_t** shadowRow, SLayerAlpha* layers, uint32_t size, uint8_t** alphaRows);
|
||||
static void SetupAlphaRows4444(uint32_t size, uint8_t** shadowRow, uint8_t** alphaRows, SLayerAlpha* layers, uint8_t** shadowCursor);
|
||||
static void __stdcall UnpackAlphaBitsFixed4444Mip0(uint16_t* dst, uint32_t size, SLayerAlpha* layer);
|
||||
static void __stdcall UnpackAlphaBitsFixed4444Mip1(uint16_t* dst, uint32_t size, SLayerAlpha* layer);
|
||||
static void __stdcall UnpackAlphaBitsUnfixed4444Mip0(uint16_t* dst, uint32_t size, SLayerAlpha* layer);
|
||||
static void __stdcall UnpackAlphaBitsUnfixed4444Mip1(uint16_t* dst, uint32_t size, SLayerAlpha* layer);
|
||||
static void __stdcall ExpandShadowBitsToTexels(uint16_t* dst, uint32_t size, uint8_t* shadowMap);
|
||||
static void __stdcall ExpandShadowBitsToTexelsMip(uint16_t* dst, uint32_t size, uint8_t* shadowMap);
|
||||
static void __stdcall UnpackAlphaShadowBitsFixed8888Mip0(CImVector* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, int32_t alphaSlot, uint8_t* shadowMap);
|
||||
static void __stdcall UnpackAlphaShadowBitsFixed8888Mip1(CImVector* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, int32_t alphaSlot, uint8_t* shadowMap);
|
||||
static void __stdcall UnpackAlphaShadowBitsFixed4444Mip0(uint16_t* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, uint8_t* shadowMap);
|
||||
static void __stdcall UnpackAlphaShadowBitsFixed4444Mip1(uint16_t* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, uint8_t* shadowMap);
|
||||
static void PackAlphaShadow4444(uint16_t* dst, uint8_t** alphaRows, uint8_t* shadowRow, uint32_t size);
|
||||
static void __stdcall UnpackAlphaShadowBitsUnfixed4444Mip0(uint16_t* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, uint8_t* shadowMap);
|
||||
static void __stdcall UnpackAlphaShadowBitsUnfixed4444Mip1(uint16_t* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, uint8_t* shadowMap);
|
||||
static void __stdcall RecreateAlphaBitsFixed8888Mip0(CImVector* dst, uint32_t size, SLayerAlpha* layer, uint8_t* shadowMap);
|
||||
static void __stdcall RecreateAlphaBitsFixed8888Mip1(CImVector* dst, uint32_t size, SLayerAlpha* layer, uint8_t* shadowMap);
|
||||
|
||||
/* 0000 */ TSLink<CMapRenderChunk> m_renderChunkLink;
|
||||
/* 0008 */ uint8_t m_unkFlags;
|
||||
/* 0009 */ uint8_t m_layersCount;
|
||||
/* 000A */ int16_t unk_000A;
|
||||
/* 000C */ float m_lastUpdateTime;
|
||||
/* 0010 */ CMapChunk* m_mapChunkPtr1;
|
||||
/* 0014 */ CMapChunk* m_mapChunkPtr2;
|
||||
/* 0010 */ CMapChunk* m_mapChunks [2];
|
||||
/* 0018 */ C3Vector m_vec1;
|
||||
/* 0024 */ CAaSphere m_sphere;
|
||||
/* 0034 */ CMapRenderChunkLayer m_layers [4];
|
||||
@@ -82,6 +140,64 @@ class CMapRenderChunk {
|
||||
/* 0088 */ CTexture* m_shadowTexture;
|
||||
/* 008C */ CMapChunkBuf* m_chunkBuf;
|
||||
/* 0090 */ CGxBatch m_batch;
|
||||
|
||||
~CMapRenderChunk();
|
||||
CMapRenderChunk();
|
||||
void AddBatch(CMapChunk* chunk1, CMapChunk* chunk2, C3Vector* position, uint8_t flags);
|
||||
void RenderPrep();
|
||||
void CreateLayers();
|
||||
void CreateLayer(CMapArea* area, SMLayer* layer, int32_t checkDuplicate);
|
||||
void AllocLayerTextures();
|
||||
void AllocShaderTexture();
|
||||
void AllocLayerTexture(CMapRenderChunkLayer* layer);
|
||||
void AllocShadowTexture();
|
||||
void UpdateLoaded();
|
||||
void UseStreamingBufs();
|
||||
void RenderPrepBufs(CGxBuf* vertexBuf, CGxBuf* indexBuf);
|
||||
void CreateShaderTexture();
|
||||
void CreateChunkLayerTex(CMapRenderChunkLayer* layer);
|
||||
void CreateShadowTex();
|
||||
void CollectLayerAlphaPtrs(CMapChunk* chunk, SLayerAlpha* layers);
|
||||
void UnpackAlphaShadowBits(void* dstBase, int32_t dstOffset, int32_t dstPitch, uint32_t size, SLayerAlpha* cursors, int32_t alphaSlot, uint8_t* shadowMap, int32_t genFormat, int32_t doNotFixAlphaMap);
|
||||
void UnpackAlphaBitsFixed8888Mip0(CImVector* dst, uint32_t size, uint8_t* shadowMap);
|
||||
void UnpackAlphaBitsFixed8888Mip1(CImVector* dst, uint32_t size, uint8_t* shadowMap);
|
||||
void UnpackAlphaBits(void* dst, uint32_t size, SLayerAlpha* layerInfo, uint8_t* shadowMap, int32_t layerMode, int32_t bigAlpha);
|
||||
void RenderSetup(int32_t a2);
|
||||
void RenderSolid();
|
||||
void RenderSolidVertexPixelShader();
|
||||
void FreeBuf();
|
||||
void FreeLayers();
|
||||
void SelectLights(CM2Lighting* lighting);
|
||||
void RenderSolidPixelShader();
|
||||
void RenderSinglePassPixelShader();
|
||||
void RenderSinglePassVertexPixelShader();
|
||||
};
|
||||
|
||||
struct CMapRenderChunk::SVertexShaderConstants {
|
||||
struct SPointLight {
|
||||
/* 0000 */ C3Vector m_position;
|
||||
/* 000C */ float m_positionW;
|
||||
/* 0010 */ C3Vector m_color;
|
||||
/* 001C */ float m_colorW;
|
||||
/* 0020 */ C3Vector m_attenuation;
|
||||
/* 002C */ float m_attenuationW;
|
||||
};
|
||||
|
||||
/* 0000 */ C44Matrix m_worldView;
|
||||
/* 0040 */ C44Matrix m_projection;
|
||||
/* 0080 */ C44Matrix m_viewTranspose;
|
||||
/* 00C0 */ C4Vector m_fog;
|
||||
/* 00D0 */ C4Vector m_texOffset [4];
|
||||
/* 0110 */ C4Vector m_texScale [6];
|
||||
/* 0170 */ C4Vector m_position;
|
||||
/* 0180 */ C4Vector m_sunDir;
|
||||
/* 0190 */ C3Vector m_sunAmbient;
|
||||
/* 019C */ float m_sunAmbientW;
|
||||
/* 01A0 */ C3Vector m_sunDiffuse;
|
||||
/* 01AC */ float m_sunDiffuseW;
|
||||
/* 01B0 */ C3Vector m_sunSpecular;
|
||||
/* 01BC */ float m_sunSpecularW;
|
||||
/* 01C0 */ SPointLight m_pointLights [3];
|
||||
};
|
||||
|
||||
struct SMMapHeader {
|
||||
@@ -90,7 +206,7 @@ struct SMMapHeader {
|
||||
/* 0008 */ uint32_t m_unused [6];
|
||||
};
|
||||
|
||||
struct TextureLayerInfo {
|
||||
struct CMapRenderChunk::SLayerAlpha {
|
||||
/* 0000 */ uint32_t m_flags;
|
||||
/* 0004 */ uint8_t* m_alphaData;
|
||||
};
|
||||
|
||||
@@ -123,4 +123,6 @@ struct SMOPortalRef {
|
||||
/* 0006 */ uint16_t m_filler;
|
||||
};
|
||||
|
||||
typedef float DepthCoordTable[256];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "WaterRipple.h"
|
||||
#include "Engine/Source/Base/Handle.h"
|
||||
#include "Engine/Source/Base/Status.h"
|
||||
#include "WoW/Source/WorldClient/Liquid.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxDevice.h"
|
||||
#include "Engine/Source/Gx/CGxDevice/CGxShader.h"
|
||||
#include "Engine/Source/Gx/CGxTexFlags.h"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "World.h"
|
||||
#include "WoW/Source/WorldClient/SortTable.h"
|
||||
#include "WoW/Source/WorldClient/CChunkLiquid.h"
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include "Engine/Source/ConsoleBase/ConsoleCommand.h"
|
||||
@@ -27,6 +29,39 @@
|
||||
#include "WoW/Source/WorldClient/Zones.h"
|
||||
#include "WoW/Source/WorldClient/Particulate.h"
|
||||
#include "WoW/Common/AaBsp.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "Engine/Source/Base/RCString.h"
|
||||
#include "WoW/Source/WorldClient/MapObjGroup.h"
|
||||
#include "Engine/Source/Tempest/C4Plane.h"
|
||||
#include "Engine/Source/Tempest/C4Vector.h"
|
||||
#include "Engine/Source/Tempest/CAaSphere.h"
|
||||
#include "Engine/Source/Tempest/CFacet.h"
|
||||
#include "Engine/Source/Tempest/CFrustum.h"
|
||||
#include "WoW/Source/WorldClient/ClipInfo.h"
|
||||
#include "Engine/Source/Model2/M2Light.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "WoW/Source/WorldClient/MapChunk.h"
|
||||
#include "WoW/Source/WorldClient/MapDoodadDef.h"
|
||||
#include "WoW/Source/WorldClient/MapEntity.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
#include "WoW/Source/WorldClient/MapLoad.h"
|
||||
#include "Engine/Source/Tempest/CMath.h"
|
||||
#include "WoW/Source/WorldClient/CPortalView.h"
|
||||
#include "Engine/Source/Tempest/CRect.h"
|
||||
#include "WoW/Source/WorldClient/CWorldMath.h"
|
||||
#include "WoW/Source/WorldClient/CWorldOcclusion.h"
|
||||
#include "WoW/Source/WorldClient/WorldView.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "Engine/Source/Gx/Types.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
#include "Engine/Source/Gx/Gx.h"
|
||||
#include "Engine/Source/Gxu/Gxu.h"
|
||||
#include "Engine/Source/Gx/CGxMatrixStack.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/FrameTime.h"
|
||||
#include "WoW/Source/Object/WGUID.h"
|
||||
#include "Engine/Source/Gxu/GxuLight.h"
|
||||
|
||||
// STATIC: 0x00ADEE48
|
||||
static const char* s_zonePaths[11] = {
|
||||
@@ -202,6 +237,31 @@ uint32_t World::s_texCacheOverride;
|
||||
// STATIC: 0x00CDFFD0
|
||||
int32_t World::s_waterLOD;
|
||||
|
||||
// STATIC: 0x00CD8790
|
||||
float s_viewerLiquidDepth;
|
||||
|
||||
|
||||
// STATIC: 0x00CD8798
|
||||
int32_t CWorldScene::frustumIndex;
|
||||
|
||||
// STATIC: 0x00CDB108
|
||||
C3Vector CWorldScene::s_frustumCorners[8];
|
||||
|
||||
// STATIC: 0x00CDB168
|
||||
CWFrustum CWorldScene::frustumStack[32];
|
||||
|
||||
// STATIC: 0x00CD8F90
|
||||
C4Plane CWorldScene::camPlaneXY;
|
||||
|
||||
// STATIC: 0x00CD9048
|
||||
CSortTable CWorldScene::sortTable;
|
||||
|
||||
// STATIC: 0x00CDFFF4
|
||||
CALLBACK_FUNC World::s_loadProgressCallback;
|
||||
|
||||
// STATIC: 0x00CDFFF0
|
||||
void* World::s_loadProgressParam;
|
||||
|
||||
// VERIFY: 8564474b manual
|
||||
// OFFSET: 0x005EEB70
|
||||
void World::SetTexLodBias(float bias) {
|
||||
@@ -284,6 +344,65 @@ static void ZonesInitialize() {
|
||||
}
|
||||
}
|
||||
|
||||
// VERIFY: 6886f483 auto
|
||||
// OFFSET: 0x0077F1E0
|
||||
int32_t World::QueryObjectLiquid(CMapEntity* entity, int32_t* liquidType, float* height, int32_t* a4) {
|
||||
if (!entity || !(entity->unk_007C & 0x20)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*height = entity->unk_0080;
|
||||
*liquidType = entity->unk_00BC;
|
||||
*a4 = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: 52533b77 auto
|
||||
// OFFSET: 0x0077F220
|
||||
int32_t World::QueryObjectLiquidFlags(CMapEntity* entity, int32_t* flag8, int32_t* flag9) {
|
||||
if (!entity || !(entity->unk_007C & 0x20)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*flag8 = (entity->unk_007C >> 8) & 1;
|
||||
*flag9 = (entity->unk_007C >> 9) & 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: 305f137e auto
|
||||
// OFFSET: 0x0077F360
|
||||
int32_t World::QueryLiquidStatus(C3Vector* pos, int32_t* liquidType, float* height) {
|
||||
int32_t a4 = 0;
|
||||
return CMap::QueryLiquidStatus(pos, liquidType, height, &a4, 0);
|
||||
}
|
||||
|
||||
// VERIFY: d8d97f86 auto
|
||||
// OFFSET: 0x0077F390
|
||||
int32_t World::QueryLiquidSounds(CMapEntity* entity, float radius, uint32_t* results) {
|
||||
if (entity->unk_007C & 0x1) {
|
||||
uint32_t distance = 9999;
|
||||
entity->QueryLiquidSounds(results, &distance);
|
||||
|
||||
if (distance < 2) {
|
||||
CMap::QueryLiquidSounds(&entity->m_position, radius, results);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMap::QueryLiquidSounds(&entity->m_position, radius, results);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: baf0a035 auto
|
||||
// OFFSET: 0x0077F400
|
||||
void World::CreateWaterRipple(const C3Vector& pos, float a2, float a3, float a4, float a5, float a6, int32_t a7, int32_t a8) {
|
||||
CMap::CreateWaterRipple(pos, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
// VERIFY: e146f1dc auto
|
||||
// OFFSET: 0x0077F490
|
||||
void World::SetNearClip(float nearClip) {
|
||||
@@ -302,6 +421,28 @@ void World::SetHorizonNearClipScale(float scale) {
|
||||
World::s_horizonNearClipScale = scale;
|
||||
}
|
||||
|
||||
// VERIFY: 7db3332e auto
|
||||
// OFFSET: 0x00780620
|
||||
int32_t World::SceneCamLiquidStatus(float* depth) {
|
||||
if (depth) {
|
||||
*depth = s_viewerLiquidDepth;
|
||||
}
|
||||
|
||||
return s_liquidTypeId;
|
||||
}
|
||||
|
||||
// VERIFY: fa04a252 auto
|
||||
// OFFSET: 0x00780640
|
||||
C3Vector* World::GetCamPos() {
|
||||
return &CWorldScene::s_activeWorldView;
|
||||
}
|
||||
|
||||
// VERIFY: 21d7eb14 auto
|
||||
// OFFSET: 0x00780650
|
||||
C3Vector* CWorldScene::GetCamTarget() {
|
||||
return &CWorldScene::camTarget;
|
||||
}
|
||||
|
||||
// VERIFY: bf7ac74d auto
|
||||
// OFFSET: 0x00780710
|
||||
void World::SetDetailDoodadDensity(int32_t density) {
|
||||
@@ -530,3 +671,362 @@ void CWorld::Initialize() {
|
||||
|
||||
ZonesInitialize();
|
||||
}
|
||||
|
||||
// VERIFY: 0ee74c0d auto
|
||||
// OFFSET: 0x00406DE0
|
||||
bool World::IsValidPosition(float x, float y, float z, float a4) {
|
||||
if (_finite(x) && _finite(y) && _finite(z)) {
|
||||
float v4 = -(y - 17066.666f);
|
||||
float v5 = -(x - 17066.666f);
|
||||
if (a4 > v4)
|
||||
return 0;
|
||||
if (34133.332f - a4 > v4 && a4 <= v5 && v5 < 34133.332f - a4)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: 91f1484d auto
|
||||
// OFFSET: 0x0077F8D0
|
||||
int32_t World::GetFlightBoundsLower(const C3Vector& pos, float* height) {
|
||||
return CMap::GetFlightBounds(pos, height, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// OFFSET: 0x00783910
|
||||
bool World::GetFacets(CAaBox* a1, CAaBox* a2, FacetData* a3, uint32_t a4, uint32_t* a5) {
|
||||
a3->facets.SetCount(0);
|
||||
a3->facetIds.SetCount(0);
|
||||
if (a5)
|
||||
*a5 = 0;
|
||||
if ((a4 & 0x4000) == 0)
|
||||
return CMap::GetFacets(a1, a2, a3, a4, a5) != 0;
|
||||
|
||||
static FacetData facetData = FacetData();
|
||||
|
||||
facetData.facets.SetCount(0);
|
||||
facetData.facetIds.SetCount(0);
|
||||
if (!CMap::GetFacets(a1, a2, &facetData, a4, a5))
|
||||
return 0;
|
||||
|
||||
for (int32_t i = 0; i < facetData.facets.Count(); i++) {
|
||||
if (facetData.facets[i].plane.n.z >= 0.64278764f) {
|
||||
a3->facets.Add(1, &facetData.facets[i]);
|
||||
a3->facetIds.Add(1, &facetData.facetIds[i]);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: 9d92b389 auto
|
||||
// OFFSET: 0x0078FB00
|
||||
void CWorldScene::FrustumXform(C44Matrix& mat) {
|
||||
CWorldScene::frustumStack[CWorldScene::frustumIndex].Transform(mat);
|
||||
}
|
||||
|
||||
// VERIFY: ad5c1827 auto
|
||||
// OFFSET: 0x0078FB20
|
||||
int32_t CWorldScene::FrustumCull(CAaBox* box) {
|
||||
return CWorldScene::frustumStack[CWorldScene::frustumIndex].Cull(*box) == 0;
|
||||
}
|
||||
|
||||
// VERIFY: 7ebc59b0 auto
|
||||
// OFFSET: 0x0078FB50
|
||||
void CWorldScene::FrustumPop() {
|
||||
CWorldScene::frustumIndex--;
|
||||
}
|
||||
|
||||
// OFFSET: 0x00790650
|
||||
void CWorldScene::GetNearestCornerToCamera(CAaBox* box, C3Vector* outCorner) {
|
||||
outCorner->x = (CWorldScene::camTarget.x >= CWorldScene::s_activeWorldView.x)
|
||||
? box->b.x
|
||||
: box->t.x;
|
||||
|
||||
outCorner->y = (CWorldScene::camTarget.y >= CWorldScene::s_activeWorldView.y)
|
||||
? box->b.y
|
||||
: box->t.y;
|
||||
|
||||
outCorner->z = (CWorldScene::camTarget.z >= CWorldScene::s_activeWorldView.z)
|
||||
? box->b.z
|
||||
: box->t.z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: d30349f9 auto
|
||||
// OFFSET: 0x00790A80
|
||||
void CWorldScene::RenderLiquidPass() {
|
||||
CWorldScene::ApplyFogState();
|
||||
|
||||
if ((CWorld::enables & Enable_Water) && CWorldScene::s_unk_CD8610) {
|
||||
CWorldScene::s_unk_CD8610->Flush(CWorldScene::s_activeWorldView, 1);
|
||||
}
|
||||
|
||||
CMap::RenderWaterRipples();
|
||||
}
|
||||
|
||||
// VERIFY: d2772b54 manual
|
||||
// OFFSET: 0x00790AF0
|
||||
void CWorldScene::FrustumSet(CRect* rect) {
|
||||
C3Vector corners[8];
|
||||
|
||||
for (uint32_t i = 0; i < 8; i += 4) {
|
||||
C3Vector* src = &CWorldScene::s_frustumCorners[i];
|
||||
|
||||
C3Vector edgeTop(src[2].x - src[1].x, src[2].y - src[1].y, src[2].z - src[1].z);
|
||||
C3Vector topLeft(edgeTop.x * rect->minX + src[1].x, edgeTop.y * rect->minX + src[1].y, edgeTop.z * rect->minX + src[1].z);
|
||||
C3Vector topRight(edgeTop.x * rect->maxX + src[1].x, edgeTop.y * rect->maxX + src[1].y, edgeTop.z * rect->maxX + src[1].z);
|
||||
|
||||
C3Vector edgeBottom(src[3].x - src[0].x, src[3].y - src[0].y, src[3].z - src[0].z);
|
||||
C3Vector bottomLeft(edgeBottom.x * rect->minX + src[0].x, edgeBottom.y * rect->minX + src[0].y, edgeBottom.z * rect->minX + src[0].z);
|
||||
C3Vector bottomRight(edgeBottom.x * rect->maxX + src[0].x, edgeBottom.y * rect->maxX + src[0].y, edgeBottom.z * rect->maxX + src[0].z);
|
||||
|
||||
C3Vector left(topLeft.x - bottomLeft.x, topLeft.y - bottomLeft.y, topLeft.z - bottomLeft.z);
|
||||
corners[i + 0] = C3Vector(left.x * rect->minY + bottomLeft.x, left.y * rect->minY + bottomLeft.y, left.z * rect->minY + bottomLeft.z);
|
||||
corners[i + 1] = C3Vector(left.x * rect->maxY + bottomLeft.x, left.y * rect->maxY + bottomLeft.y, left.z * rect->maxY + bottomLeft.z);
|
||||
|
||||
C3Vector right(topRight.x - bottomRight.x, topRight.y - bottomRight.y, topRight.z - bottomRight.z);
|
||||
corners[i + 3] = C3Vector(right.x * rect->minY + bottomRight.x, right.y * rect->minY + bottomRight.y, right.z * rect->minY + bottomRight.z);
|
||||
corners[i + 2] = C3Vector(right.x * rect->maxY + bottomRight.x, right.y * rect->maxY + bottomRight.y, right.z * rect->maxY + bottomRight.z);
|
||||
}
|
||||
|
||||
CWorldScene::frustumStack[CWorldScene::frustumIndex].CalcPlanesFromCorners(corners);
|
||||
}
|
||||
|
||||
// VERIFY: d9802889 auto
|
||||
// OFFSET: 0x00791100
|
||||
void CWorldScene::FrustumSet(CFrustum* frustum) {
|
||||
static_cast<CFrustum&>(CWorldScene::frustumStack[CWorldScene::frustumIndex]) = *frustum;
|
||||
}
|
||||
|
||||
// VERIFY: 939d636d auto
|
||||
// OFFSET: 0x00791120
|
||||
int32_t CWorldScene::FrustumCull(const C3Vector& center, float radius) {
|
||||
CAaSphere sphere;
|
||||
sphere.c = center;
|
||||
sphere.r = radius;
|
||||
|
||||
return CWorldScene::frustumStack[CWorldScene::frustumIndex].Cull(sphere) == 0;
|
||||
}
|
||||
|
||||
// OFFSET: 0x00791640
|
||||
bool World::NDCXform(CFrustum* frustum, C44Matrix* out, bool includeTranslation) {
|
||||
C3Vector* corners = frustum->corners;
|
||||
|
||||
float ax = corners[3].x - corners[0].x;
|
||||
float ay = corners[3].y - corners[0].y;
|
||||
float az = corners[3].z - corners[0].z;
|
||||
|
||||
float bx = corners[1].x - corners[0].x;
|
||||
float by = corners[1].y - corners[0].y;
|
||||
float bz = corners[1].z - corners[0].z;
|
||||
|
||||
float cx = corners[4].x - corners[0].x;
|
||||
float cy = corners[4].y - corners[0].y;
|
||||
float cz = corners[4].z - corners[0].z;
|
||||
|
||||
*out = C44Matrix();
|
||||
|
||||
out->a0 = ax;
|
||||
out->a1 = ay;
|
||||
out->a2 = az;
|
||||
out->b0 = bx;
|
||||
out->b1 = by;
|
||||
out->b2 = bz;
|
||||
out->c0 = cx;
|
||||
out->c1 = cy;
|
||||
out->c2 = cz;
|
||||
|
||||
if (includeTranslation) {
|
||||
out->d0 = corners[0].x;
|
||||
out->d1 = corners[0].y;
|
||||
out->d2 = corners[0].z;
|
||||
}
|
||||
|
||||
float det = out->Determinant();
|
||||
|
||||
if (fabs(det) < 0.00000023841858f) {
|
||||
*out = C44Matrix();
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = out->Inverse(det);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: 4c456906 auto
|
||||
// OFFSET: 0x00791950
|
||||
void CWorldScene::FrustumPush() {
|
||||
CWorldScene::frustumIndex++;
|
||||
static_cast<CFrustum&>(CWorldScene::frustumStack[CWorldScene::frustumIndex]) = CWorldScene::frustumStack[CWorldScene::frustumIndex - 1];
|
||||
}
|
||||
|
||||
// VERIFY: b58d1116 manual
|
||||
// OFFSET: 0x00792DF0
|
||||
void CWorldScene::AddToDistanceBucket(CChunkLiquid* liquid, const C3Vector& pos) {
|
||||
int32_t bucket = 0;
|
||||
float distance = pos.y * CWorldScene::camPlaneXY.n.y + pos.z * CWorldScene::camPlaneXY.n.z + pos.x * CWorldScene::camPlaneXY.n.x + CWorldScene::camPlaneXY.d;
|
||||
|
||||
if (distance > 0.0f) {
|
||||
float scaled = distance * 0.03f;
|
||||
bucket = CMath::fint_(scaled - 0.5f);
|
||||
|
||||
if (bucket >= 64) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CWorldScene::sortTable.m_table[bucket].m_liquidList.LinkToTail(liquid);
|
||||
}
|
||||
|
||||
// OFFSET: 0x00792FC0
|
||||
void CWorldScene::AddViewerGroup(TSGrowableArray<uint16_t>* group, uint16_t val) {
|
||||
for (int32_t i = 0; i < group->Count(); i++) {
|
||||
if (group->Ptr()[i] == val) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
group->Add(1, &val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// VERIFY: 44ac3c58 auto
|
||||
// OFFSET: 0x007935A0
|
||||
void CWorldScene::CullLiquid(CSortEntry* entry) {
|
||||
if (!(CWorld::enables & Enable_Water)) {
|
||||
CChunkLiquid* liquid = entry->m_liquidList.Head();
|
||||
|
||||
while (liquid) {
|
||||
CChunkLiquid* next = entry->m_liquidList.Next(liquid);
|
||||
CMap::s_mapChunkLiquidUpdateList.LinkToTail(liquid);
|
||||
liquid = next;
|
||||
}
|
||||
} else {
|
||||
CChunkLiquid* liquid = entry->m_liquidList.Head();
|
||||
|
||||
while (liquid) {
|
||||
CChunkLiquid* next = entry->m_liquidList.Next(liquid);
|
||||
CMap::s_mapChunkLiquidUpdateList.LinkToTail(liquid);
|
||||
|
||||
CAaBox box;
|
||||
liquid->GetAaBox(box);
|
||||
|
||||
if (CWorldScene::frustumStack[CWorldScene::frustumIndex].Cull(box) && !CWorldOcclusion::QueryBuffer(&box, 0) && !CWorldOcclusion::QueryVolumes(liquid->GetSphere())) {
|
||||
liquid->RenderPrep();
|
||||
|
||||
if (CWorldScene::s_unk_CD8610 && liquid->m_instance) {
|
||||
CWorldScene::s_unk_CD8610->Draw(liquid->m_instance);
|
||||
}
|
||||
}
|
||||
|
||||
liquid = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x007A3E40
|
||||
void World::AddAaBoxFacets(CAaBox* box, FacetData* facets) {
|
||||
static const int32_t s_boxTriIndex[36] = { 0, 2, 3, 0, 1, 2, 1, 6, 2, 1, 5, 6, 4, 6, 5, 4, 7, 6, 0, 7, 4, 0, 3, 7, 0, 5, 1, 0, 4, 5, 2, 7, 3, 2, 6, 7 };
|
||||
|
||||
if (box->t.x <= box->b.x || box->t.y <= box->b.y || box->t.z <= box->b.z)
|
||||
return;
|
||||
|
||||
uint32_t firstFacet = facets->facets.Count();
|
||||
|
||||
C3Vector corner[8];
|
||||
corner[0] = { box->b.x, box->t.y, box->b.z };
|
||||
corner[1] = { box->t.x, box->t.y, box->b.z };
|
||||
corner[2] = { box->t.x, box->b.y, box->b.z };
|
||||
corner[3] = { box->b.x, box->b.y, box->b.z };
|
||||
corner[4] = { box->b.x, box->t.y, box->t.z };
|
||||
corner[5] = { box->t.x, box->t.y, box->t.z };
|
||||
corner[6] = { box->t.x, box->b.y, box->t.z };
|
||||
corner[7] = { box->b.x, box->b.y, box->t.z };
|
||||
|
||||
C4Plane plane[6];
|
||||
plane[0].From3Pos(corner[0], corner[2], corner[3]);
|
||||
plane[1].From3Pos(corner[1], corner[6], corner[2]);
|
||||
plane[2].From3Pos(corner[4], corner[6], corner[5]);
|
||||
plane[3].From3Pos(corner[0], corner[7], corner[4]);
|
||||
plane[4].From3Pos(corner[0], corner[5], corner[1]);
|
||||
plane[5].From3Pos(corner[2], corner[7], corner[3]);
|
||||
|
||||
CFacet facet(0.0f);
|
||||
for (int32_t i = 0; i < 36; i += 3) {
|
||||
facet.plane = plane[i / 6];
|
||||
facet.v[0] = corner[s_boxTriIndex[i]];
|
||||
facet.v[1] = corner[s_boxTriIndex[i + 1]];
|
||||
facet.v[2] = corner[s_boxTriIndex[i + 2]];
|
||||
facets->facets.Add(1, &facet);
|
||||
}
|
||||
|
||||
uint32_t count = facets->facets.Count();
|
||||
facets->facetIds.SetCount(count);
|
||||
for (uint32_t i = firstFacet; i < count; i++)
|
||||
facets->facetIds[i] = 0;
|
||||
}
|
||||
|
||||
// OFFSET: 0x007A6B90
|
||||
void CWorldScene::CalcScreenRectFromVerts(CRect& rect, C3Vector* clippedVerts, uint32_t clippedCount) {
|
||||
rect.minX = 3.4028235e38;
|
||||
rect.maxX = -3.4028235e38;
|
||||
rect.maxY = -3.4028235e38;
|
||||
rect.minY = 3.4028235e38;
|
||||
|
||||
for (uint32_t i = 0; i < clippedCount; i++) {
|
||||
if (rect.minX > clippedVerts[i].x)
|
||||
rect.minX = clippedVerts[i].x;
|
||||
if (rect.maxX < clippedVerts[i].x)
|
||||
rect.maxX = clippedVerts[i].x;
|
||||
if (rect.minY > clippedVerts[i].y)
|
||||
rect.minY = clippedVerts[i].y;
|
||||
if (rect.maxY < clippedVerts[i].y)
|
||||
rect.maxY = clippedVerts[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,25 @@
|
||||
#include "Engine/Source/Tempest/C3Vector.h"
|
||||
#include "Engine/Source/Event/Types.h"
|
||||
#include "Engine/Source/Storm/H/stpl.h"
|
||||
#include "WoW/Source/WorldClient/CMapBaseObjLink.h"
|
||||
#include "Engine/Source/Tempest/CRect.h"
|
||||
#include "Engine/Source/Tempest/C4Plane.h"
|
||||
#include "Engine/Source/Tempest/C4Vector.h"
|
||||
#include "Engine/Source/Tempest/CWFrustum.h"
|
||||
#include "WoW/Source/Object/WGUID.h"
|
||||
|
||||
class CAaSphere;
|
||||
class CFacet;
|
||||
class CFrustum;
|
||||
class CM2Lighting;
|
||||
class CM2Model;
|
||||
class CMapBaseObjLink;
|
||||
class CMapObj;
|
||||
class CMapObjDef;
|
||||
class CMapObjDefGroup;
|
||||
class CPortalView;
|
||||
struct SMOPortal;
|
||||
struct SMOPortalRef;
|
||||
|
||||
class CAaBox;
|
||||
class C44Matrix;
|
||||
@@ -26,6 +42,10 @@ class CTexture;
|
||||
class Particulate;
|
||||
class Weather;
|
||||
|
||||
typedef void (*CALLBACK_FUNC)(float, void*);
|
||||
|
||||
class CChunkLiquid;
|
||||
class CDetailDoodadInst;
|
||||
class CMapBaseObj;
|
||||
class CMapChunk;
|
||||
class CMapDoodadDef;
|
||||
@@ -40,13 +60,15 @@ class CMapDoodadDefMapChunkLink {
|
||||
/* 0014 */ TSLink<CMapDoodadDefMapChunkLink> m_ownerLink;
|
||||
};
|
||||
|
||||
class CSortTable;
|
||||
|
||||
class CSortEntry {
|
||||
public:
|
||||
/* 0000 */ TSExplicitList<CMapChunk> m_mapChunkList;
|
||||
/* 000C */ TSList<void> m_exteriorGroupList;
|
||||
/* 0018 */ TSList<void> m_entityList;
|
||||
/* 0024 */ TSList<void> m_doodadDefList;
|
||||
/* 0030 */ TSList<void> m_liquidList;
|
||||
/* 0030 */ TSList<CChunkLiquid, TSGetExplicitLink<CChunkLiquid> > m_liquidList;
|
||||
/* 003C */ TSList<void> m_occluderList;
|
||||
/* 0048 */ TSList<void> m_unkList7;
|
||||
/* 0054 */ TSList<void> m_holedChunkList;
|
||||
@@ -91,11 +113,19 @@ class CWorldScene {
|
||||
public:
|
||||
static Liquid::CRenderer* s_unk_CD8610;
|
||||
static TSExplicitList<CWFrustum, offsetof(CWFrustum, m_link)> frustumFreeList;
|
||||
static int32_t frustumIndex;
|
||||
static C3Vector s_frustumCorners[8];
|
||||
static CWFrustum frustumStack[32];
|
||||
static GxuScene s_unk_B2EB68;
|
||||
static CTexture* s_defaultBlendTexture;
|
||||
static CTexture* s_defaultTexture;
|
||||
static float s_unk_CD877C;
|
||||
static CMapEntity* camTargetEntity;
|
||||
static C3Vector s_activeWorldView;
|
||||
static C3Vector camTarget;
|
||||
static C4Plane camPlaneXY;
|
||||
static CSortTable sortTable;
|
||||
static CMapObjDef* s_curMapObjDef;
|
||||
static float s_fadeDist[5];
|
||||
static float s_fadeDistDefault[5];
|
||||
static float s_fadeDistMin[5];
|
||||
@@ -108,6 +138,64 @@ class CWorldScene {
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static void ScaleFadeDist(float scale);
|
||||
static void Update(C3Vector* camPos, C3Vector* camTarget);
|
||||
static void GetNearestCornerToCamera(CAaBox* box, C3Vector* outCorner);
|
||||
static void AddMapChunk(CMapChunk* mapChunk);
|
||||
static void AddMapObjDefGroup(CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup);
|
||||
static void AddMapChunkToRenderList(CMapChunk* mapChunk, C3Vector* pos);
|
||||
static void AddMapObjDefGroupToSortTable(uint32_t groupNum, CMapObjDef* mapObjDef);
|
||||
static void AddEntityToSortTable(CMapEntity* entity);
|
||||
static CFrustum* AllocFrustum();
|
||||
static int32_t FrustumCull(CAaBox* box);
|
||||
static int32_t FrustumCull(const C3Vector& center, float radius);
|
||||
static void FrustumSet(C3Vector* corners, CRect* rect);
|
||||
static void FrustumSet(CRect* rect);
|
||||
static void FrustumSet(CFrustum* frustum);
|
||||
static void FrustumPush();
|
||||
static void FrustumPop();
|
||||
static void FrustumXform(C44Matrix& mat);
|
||||
static bool InsideFrustumRect(CiRect* rect);
|
||||
static C3Vector* GetCamTarget();
|
||||
static void ApplyFogState();
|
||||
static void RenderLiquidPass();
|
||||
static void CullSortTable(CRect* a1);
|
||||
static void CullDoodads(CSortEntry* entry, uint8_t fadeLevel);
|
||||
static void CullLiquid(CSortEntry* entry);
|
||||
static void AddChunkToSortList(CDetailDoodadInst* inst);
|
||||
static void AddToDistanceBucket(CChunkLiquid* liquid, const C3Vector& pos);
|
||||
static void AddDoodadDefModelToModelScene(CMapDoodadDef* a1);
|
||||
static void AddDoodadDefs(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* linkList, uint32_t a2);
|
||||
static void CullDoodadsExterior(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* linkList, uint8_t fadeLevel);
|
||||
static void CullMapObjDefGroup();
|
||||
static void CullMapObjDefGroups(CSortEntry* entry, CRect* a2, uint32_t a3);
|
||||
static void CullMapObjDefGroupFromExterior(CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup, CRect* a3, uint32_t a4);
|
||||
static void CullEntitys(CSortEntry* entry);
|
||||
static void CullThroughPortal(CRect* rect);
|
||||
static void CullDoodadsInterior(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* linkList, CFrustum* frustumList, uint8_t fadeLevel, int32_t interior);
|
||||
static void CullEntitysInterior(TSExplicitList<CMapBaseObjLink, offsetof(CMapBaseObjLink, m_refLink)>* linkList, CFrustum* frustumList, int32_t force, int32_t interior);
|
||||
static void CullChunks(CSortEntry* entry, int32_t index);
|
||||
static void Render(const C3Vector& cameraPos, float time);
|
||||
static void RenderChunks();
|
||||
static void RenderMapObjDefGroups();
|
||||
static void SetWorldProjection(C44Matrix& mat);
|
||||
static void RenderChunksSolid();
|
||||
static void SetupMapObjDefCull(CMapObj* mapObj, C44Matrix& a2, C44Matrix& a3, C3Vector& a4, C3Vector& a5);
|
||||
static void RenderThruPortalsExterior(CMapObj* mapObj, C44Matrix& mat, C44Matrix& invMat, C3Vector& worldPos, C3Vector& camTarget, CRect& a6, int32_t a7);
|
||||
static void RenderInterior(CMapObj* mapObj, C44Matrix& mat, C44Matrix& invMat, C3Vector& worldPos, C3Vector& camTarget, TSGrowableArray<uint16_t>* groups);
|
||||
static void RenderThruPortals(CMapObj* mapObj, uint32_t groupNum, uint32_t fromGroup, CRect& ndcRect, uint32_t depth, int32_t interior);
|
||||
static void PushPortalView(CPortalView* portalView);
|
||||
static void TransformPortal(CMapObj* mapObj, SMOPortal* portal, SPortalExt* portalExt);
|
||||
static void ClassifyPortalPlane(CMapObj* mapObj, SMOPortal* portal, SPortalExt* portalExt);
|
||||
static uint32_t TransformAndClipVerts(CMapObj* mapObj, uint32_t a2, C3Vector* verts, uint32_t vertCount, C3Vector& a5, C3Vector*& clippedVerts, uint32_t& clippedCount);
|
||||
static void ClipVerts(C3Vector* verts, uint32_t count, C3Vector** outVerts, uint32_t* outCount);
|
||||
static void CalcScreenRectFromVerts(CRect& rect, C3Vector* clippedVerts, uint32_t clippedCount);
|
||||
static void LocateViewer3();
|
||||
static void RenderCollisionDebug();
|
||||
static void AddViewerGroup(TSGrowableArray<uint16_t>* group, uint16_t val);
|
||||
static void AddExteriorPortalView(CMapObj* mapObj, SMOPortal* portal, SMOPortalRef* ref, SPortalExt* ext, uint32_t destIsExterior);
|
||||
static void AddInteriorPortalView(CMapObj* mapObj, SMOPortal* portal, SMOPortalRef* ref, SPortalExt* ext, TSGrowableArray<CPortalView>* a5);
|
||||
static void SetupLighting(CM2Lighting* lighting, C3Vector* view);
|
||||
static void SetCameraTarget(CMapEntity* entity, WGUID transportGuid);
|
||||
|
||||
/* 0000 */ uint8_t unk_0000[16];
|
||||
/* 0010 */ uint32_t unk_0010;
|
||||
@@ -140,7 +228,26 @@ class CWorldScene {
|
||||
};
|
||||
|
||||
namespace World {
|
||||
extern CALLBACK_FUNC s_loadProgressCallback;
|
||||
extern void* s_loadProgressParam;
|
||||
|
||||
C3Vector* GetCamPos();
|
||||
void CreateWaterRipple(const C3Vector& pos, float a2, float a3, float a4, float a5, float a6, int32_t a7, int32_t a8);
|
||||
int32_t QueryLiquidSounds(CMapEntity* entity, float radius, uint32_t* results);
|
||||
int32_t QueryLiquidStatus(C3Vector* pos, int32_t* liquidType, float* height);
|
||||
int32_t QueryObjectLiquid(CMapEntity* entity, int32_t* liquidType, float* height, int32_t* a4);
|
||||
int32_t QueryObjectLiquidFlags(CMapEntity* entity, int32_t* flag8, int32_t* flag9);
|
||||
int32_t SceneCamLiquidStatus(float* depth);
|
||||
|
||||
class FacetData {
|
||||
public:
|
||||
TSGrowableArray<CFacet> facets;
|
||||
TSGrowableArray<uint64_t> facetIds;
|
||||
};
|
||||
|
||||
extern CM2Scene* s_m2Scene;
|
||||
extern float s_viewerLiquidDepth;
|
||||
extern uint32_t s_liquidTypeId;
|
||||
extern Weather* s_weather;
|
||||
extern float groundEffectDistValueSqr;
|
||||
extern C4Vector texVect[8];
|
||||
@@ -170,6 +277,14 @@ void SetHorizonNearClipScale(float scale);
|
||||
void SetNearClip(float nearClip);
|
||||
void SetTexLodBias(float bias);
|
||||
float ValidateFarClip(float farClip, int32_t mapID);
|
||||
bool NDCClip(C3Vector* verts, uint32_t count, C3Vector*** outVerts, uint32_t* outCount);
|
||||
bool GetFacets(CAaBox* a1, CAaBox* a2, FacetData* a3, uint32_t a4, uint32_t* a5);
|
||||
bool NDCXform(CFrustum* frustum, C44Matrix* out, bool includeTranslation);
|
||||
bool IsValidPosition(float x, float y, float z, float a4);
|
||||
void AddAaBoxFacets(CAaBox* box, FacetData* facets);
|
||||
uint32_t TriDataToFacetData(void* unused, FacetData* facets, WGUID guid);
|
||||
int32_t GetFlightBoundsLower(const C3Vector& pos, float* height);
|
||||
void ObjectSetModel(CMapEntity* entity, CM2Model* model);
|
||||
}
|
||||
|
||||
class CWorld {
|
||||
@@ -177,6 +292,7 @@ class CWorld {
|
||||
static int32_t bShowSimpleDoodads;
|
||||
static int32_t bLoadSimpleDoodads;
|
||||
static Particulate* particulate;
|
||||
static int32_t s_waterRipples;
|
||||
static int32_t shadowMipLevel;
|
||||
static int32_t unk_CD7658;
|
||||
static uint32_t maxLights;
|
||||
@@ -215,6 +331,9 @@ class CWorld {
|
||||
static int32_t ConsoleCommand_WaterRipples(const char* command, const char* arguments);
|
||||
static void Destroy();
|
||||
static void Initialize();
|
||||
static void LoadMap(const char* mapName, C3Vector* position, int32_t zoneID);
|
||||
static void Update(C3Vector* camPos, C3Vector* camTarget, C3Vector* position);
|
||||
static void SetLoadProgressCallback(CALLBACK_FUNC callback, void* param);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,9 +9,14 @@
|
||||
#include "WoW/Source/DB/DBClient/DBClient.h"
|
||||
#include "WoW/Source/WorldClient/Barrier.h"
|
||||
#include "WoW/Source/WorldClient/CWorldOcclusion.h"
|
||||
#include "WoW/Source/WorldClient/Liquid.h"
|
||||
#include "WoW/Source/LiquidSystem/Liquid.h"
|
||||
#include "WoW/Source/WorldClient/LiquidWaveManager.h"
|
||||
#include "WoW/Source/WorldClient/LiquidGeomFactories.h"
|
||||
#include "WoW/Source/WorldClient/LiquidEnvironment.h"
|
||||
#include "WoW/Source/WorldClient/World.h"
|
||||
#include "WoW/Source/WorldClient/WorldView.h"
|
||||
#include "WoW/Source/WorldClient/MapObj.h"
|
||||
#include "WoW/Source/WorldClient/MapObjDef.h"
|
||||
|
||||
// STATIC: 0x00ADF350
|
||||
float CWorldScene::s_fadeSizeDefault[5] = { 1.0f, 4.0f, 15.0f, 100.0f, 100000.0f };
|
||||
@@ -58,6 +63,15 @@ CMapEntity* CWorldScene::camTargetEntity;
|
||||
// STATIC: 0x00CD87B0
|
||||
int32_t CWorldScene::s_unk_CD87B0;
|
||||
|
||||
// STATIC: 0x00CD8F5C
|
||||
C3Vector CWorldScene::s_activeWorldView;
|
||||
|
||||
// STATIC: 0x00CD8F68
|
||||
C3Vector CWorldScene::camTarget;
|
||||
|
||||
// STATIC: 0x00D1C420
|
||||
CMapObjDef* CWorldScene::s_curMapObjDef;
|
||||
|
||||
// VERIFY: ce865553 manual
|
||||
// OFFSET: 0x00798310
|
||||
void CWorldScene::Destroy() {
|
||||
@@ -152,3 +166,11 @@ void CWorldScene::ScaleFadeDist(float scale) {
|
||||
CWorldView::s_fadeDistSqr[4] = CWorldScene::s_fadeDist[4] * CWorldScene::s_fadeDist[4];
|
||||
CWorldScene::s_fadeDistMinSqr[4] = CWorldScene::s_fadeDistMin[4] * CWorldScene::s_fadeDistMin[4];
|
||||
}
|
||||
|
||||
// VERIFY: 0f630b8d auto
|
||||
// OFFSET: 0x007B3B20
|
||||
void CMapObjDef::RenderWithCallback(TSGrowableArray<uint16_t>* groups) {
|
||||
CMapObj::SetGroupRenderCallback(reinterpret_cast<RENDER_CALLBACK>(CWorldScene::AddMapObjDefGroupToSortTable), this);
|
||||
CWorldScene::s_curMapObjDef = this;
|
||||
CWorldScene::RenderInterior(this->m_owner, this->m_mat, this->m_invMat, CWorldScene::s_activeWorldView, CWorldScene::camTarget, groups);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "World.h"
|
||||
#include <cstdio>
|
||||
#include "Engine/Source/ConsoleBase/IConsole.h"
|
||||
#include "WoW/Source/WorldClient/Types.h"
|
||||
|
||||
// STATIC: 0x00ADF7F0
|
||||
int32_t CWorld::s_waterRipples = 1;
|
||||
|
||||
// VERIFY: ae98adec auto
|
||||
// OFFSET: 0x0077F690
|
||||
int32_t CWorld::ConsoleCommand_WaterRipples(const char* command, const char* arguments) {
|
||||
sscanf(arguments, "%d", &CWorld::s_waterRipples);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// VERIFY: 05445309 auto
|
||||
// OFFSET: 0x0077F6B0
|
||||
int32_t CWorld::ConsoleCommand_WaterParticulates(const char* command, const char* arguments) {
|
||||
if (CWorld::enables & 0x2000000) {
|
||||
ConsoleWrite("Particulates disabled", DEFAULT_COLOR);
|
||||
CWorld::enables &= ~0x2000000;
|
||||
} else {
|
||||
ConsoleWrite("Particulates enabled", DEFAULT_COLOR);
|
||||
CWorld::enables |= 0x2000000;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user