mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 13:41:06 +03:00
Compare commits
9 Commits
8bd4e08c80
...
0c0c936874
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c0c936874 | ||
|
|
f8f00b599e | ||
|
|
703dc26df7 | ||
|
|
09c016c935 | ||
|
|
2145348935 | ||
|
|
50685c7cc0 | ||
|
|
b3c07f0607 | ||
|
|
6bcaec1fe7 | ||
|
|
4628b7d831 |
@ -1 +1 @@
|
||||
Subproject commit dc8f10e407daa8bdf7e90d9438b55d5883780825
|
||||
Subproject commit 4ba7e0a6c3836254daf97bab159807fae6cab039
|
||||
@ -1,4 +1,5 @@
|
||||
#include "ui/simple/CSimpleCamera.hpp"
|
||||
#include "gx/Transform.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include <tempest/Math.hpp>
|
||||
|
||||
@ -63,7 +64,7 @@ CSimpleCamera::CSimpleCamera(float nearZ, float farZ, float fov) {
|
||||
this->SetFacing(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
float CSimpleCamera::FOV() {
|
||||
float CSimpleCamera::FOV() const {
|
||||
return this->m_fov;
|
||||
}
|
||||
|
||||
@ -107,6 +108,25 @@ void CSimpleCamera::SetNearZ(float nearZ) {
|
||||
this->m_nearZ = nearZ;
|
||||
}
|
||||
|
||||
void CSimpleCamera::SetGxProjectionAndView(const CRect& projRect) {
|
||||
// Projection
|
||||
|
||||
this->m_aspect = (projRect.maxX - projRect.minX) / (projRect.maxY - projRect.minY);
|
||||
|
||||
C44Matrix projMat;
|
||||
GxuXformCreateProjection_Exact(this->FOV() * 0.6f, this->m_aspect, this->m_nearZ, this->m_farZ, projMat);
|
||||
|
||||
GxXformSetProjection(projMat);
|
||||
|
||||
// View
|
||||
|
||||
C3Vector eye;
|
||||
C44Matrix viewMat;
|
||||
GxuXformCreateLookAtSgCompat(eye, this->Forward(), this->Up(), viewMat);
|
||||
|
||||
GxXformSetView(viewMat);
|
||||
}
|
||||
|
||||
C3Vector CSimpleCamera::Up() const {
|
||||
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define UI_SIMPLE_C_SIMPLE_CAMERA_HPP
|
||||
|
||||
#include <tempest/Matrix.hpp>
|
||||
#include <tempest/Rect.hpp>
|
||||
#include <tempest/Vector.hpp>
|
||||
|
||||
class CM2Scene;
|
||||
@ -9,7 +10,7 @@ class CM2Scene;
|
||||
class CSimpleCamera {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual float FOV();
|
||||
virtual float FOV() const;
|
||||
virtual C3Vector Forward() const;
|
||||
virtual C3Vector Right() const;
|
||||
virtual C3Vector Up() const;
|
||||
@ -22,6 +23,7 @@ class CSimpleCamera {
|
||||
void SetFacing(float yaw, float pitch, float roll);
|
||||
void SetFarZ(float farZ);
|
||||
void SetFieldOfView(float fov);
|
||||
void SetGxProjectionAndView(const CRect& projRect);
|
||||
void SetNearZ(float nearZ);
|
||||
|
||||
protected:
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "gx/Gx.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include "world/CWorldParam.hpp"
|
||||
#include "world/Map.hpp"
|
||||
#include "world/Weather.hpp"
|
||||
#include <storm/Memory.hpp>
|
||||
@ -10,14 +11,36 @@ uint32_t CWorld::s_curTimeMs;
|
||||
float CWorld::s_curTimeSec;
|
||||
uint32_t CWorld::s_enables;
|
||||
uint32_t CWorld::s_enables2;
|
||||
float CWorld::s_farClip;
|
||||
uint32_t CWorld::s_gameTimeFixed;
|
||||
float CWorld::s_gameTimeSec;
|
||||
CM2Scene* CWorld::s_m2Scene;
|
||||
float CWorld::s_nearClip = 0.1f;
|
||||
float CWorld::s_prevFarClip;
|
||||
uint32_t CWorld::s_tickTimeFixed;
|
||||
uint32_t CWorld::s_tickTimeMs;
|
||||
float CWorld::s_tickTimeSec;
|
||||
Weather* CWorld::s_weather;
|
||||
|
||||
namespace {
|
||||
|
||||
float AdjustFarClip(float farClip, int32_t mapID) {
|
||||
float minFarClip = 183.33333f;
|
||||
float maxFarClip = 1583.3334f;
|
||||
|
||||
if (mapID < 530 || mapID == 575 || mapID == 543) {
|
||||
if (!CWorldParam::cvar_farClipOverride || CWorldParam::cvar_farClipOverride->GetInt() < 1) {
|
||||
maxFarClip = 791.66669f;
|
||||
}
|
||||
} else if (false /* TODO OsGetPhysicalMemory() <= 1073741824 */) {
|
||||
maxFarClip = 791.66669f;
|
||||
}
|
||||
|
||||
return std::min(std::max(farClip, minFarClip), maxFarClip);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HWORLDOBJECT CWorld::AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags) {
|
||||
auto entity = CMap::AllocEntity(objFlags & 0x8 ? true : false);
|
||||
|
||||
@ -55,6 +78,10 @@ float CWorld::GetCurTimeSec() {
|
||||
return CWorld::s_curTimeSec;
|
||||
}
|
||||
|
||||
float CWorld::GetFarClip() {
|
||||
return CWorld::s_farClip;
|
||||
}
|
||||
|
||||
uint32_t CWorld::GetFixedPrecisionTime(float timeSec) {
|
||||
return static_cast<uint32_t>(timeSec * 1024.0f);
|
||||
}
|
||||
@ -71,6 +98,10 @@ CM2Scene* CWorld::GetM2Scene() {
|
||||
return CWorld::s_m2Scene;
|
||||
}
|
||||
|
||||
float CWorld::GetNearClip() {
|
||||
return CWorld::s_nearClip;
|
||||
}
|
||||
|
||||
uint32_t CWorld::GetTickTimeFixed() {
|
||||
return CWorld::s_tickTimeFixed;
|
||||
}
|
||||
@ -133,10 +164,14 @@ void CWorld::Initialize() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID) {
|
||||
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t mapID) {
|
||||
CWorld::s_farClip = AdjustFarClip(CWorldParam::cvar_farClip->GetFloat(), mapID);
|
||||
CWorld::s_nearClip = 0.2f;
|
||||
CWorld::s_prevFarClip = CWorld::s_farClip;
|
||||
|
||||
// TODO
|
||||
|
||||
CMap::Load(mapName, zoneID);
|
||||
CMap::Load(mapName, mapID);
|
||||
|
||||
// TODO
|
||||
}
|
||||
@ -147,6 +182,24 @@ int32_t CWorld::OnTick(const EVENT_DATA_TICK* data, void* param) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CWorld::SetFarClip(float farClip) {
|
||||
farClip = AdjustFarClip(farClip, CMap::s_mapID);
|
||||
|
||||
if (CWorld::s_farClip == farClip) {
|
||||
return;
|
||||
}
|
||||
|
||||
CWorld::s_prevFarClip = CWorld::s_farClip;
|
||||
CWorld::s_farClip = farClip;
|
||||
|
||||
// TODO CMapRenderChunk::DirtyPools();
|
||||
|
||||
CWorld::s_nearClip = 0.2f;
|
||||
|
||||
// TODO dword_D1C410 = 1;
|
||||
// TODO dword_ADEEE0 = 1;
|
||||
}
|
||||
|
||||
void CWorld::SetUpdateTime(float tickTimeSec, uint32_t curTimeMs) {
|
||||
auto tickTimeFixed = CWorld::GetFixedPrecisionTime(tickTimeSec);
|
||||
|
||||
|
||||
@ -57,24 +57,30 @@ class CWorld {
|
||||
static HWORLDOBJECT AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags);
|
||||
static uint32_t GetCurTimeMs();
|
||||
static float GetCurTimeSec();
|
||||
static float GetFarClip();
|
||||
static uint32_t GetGameTimeFixed();
|
||||
static float GetGameTimeSec();
|
||||
static CM2Scene* GetM2Scene();
|
||||
static float GetNearClip();
|
||||
static uint32_t GetTickTimeFixed();
|
||||
static uint32_t GetTickTimeMs();
|
||||
static float GetTickTimeSec();
|
||||
static void Initialize();
|
||||
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
||||
static void LoadMap(const char* mapName, const C3Vector& position, int32_t mapID);
|
||||
static int32_t OnTick(const EVENT_DATA_TICK* data, void* param);
|
||||
static void SetFarClip(float farClip);
|
||||
static void SetUpdateTime(float tickTimeSec, uint32_t curTimeMs);
|
||||
|
||||
private:
|
||||
// Private static variables
|
||||
static uint32_t s_curTimeMs;
|
||||
static float s_curTimeSec;
|
||||
static float s_farClip;
|
||||
static uint32_t s_gameTimeFixed;
|
||||
static float s_gameTimeSec;
|
||||
static CM2Scene* s_m2Scene;
|
||||
static float s_nearClip;
|
||||
static float s_prevFarClip;
|
||||
static uint32_t s_tickTimeFixed;
|
||||
static uint32_t s_tickTimeMs;
|
||||
static float s_tickTimeSec;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "world/CWorldParam.hpp"
|
||||
#include "world/CWorld.hpp"
|
||||
#include "console/CVar.hpp"
|
||||
|
||||
CVar* CWorldParam::cvar_baseMip;
|
||||
@ -53,7 +54,8 @@ bool CWorldParam::ExtShadowQualityCallback(CVar* var, const char* oldValue, cons
|
||||
}
|
||||
|
||||
bool CWorldParam::FarClipCallback(CVar* var, const char* oldValue, const char* value, void* arg) {
|
||||
// TODO
|
||||
CWorld::SetFarClip(SStrToFloat(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef WORLD_C_WORLD_PARAM_HPP
|
||||
#define WORLD_C_WORLD_PARAM_HPP
|
||||
|
||||
class CVar;
|
||||
#include "console/CVar.hpp"
|
||||
|
||||
class CWorldParam {
|
||||
public:
|
||||
|
||||
@ -28,6 +28,7 @@ uint32_t* CMap::s_mapObjDefGroupHeap;
|
||||
uint32_t* CMap::s_mapObjDefHeap;
|
||||
uint32_t* CMap::s_mapObjGroupHeap;
|
||||
uint32_t* CMap::s_mapObjHeap;
|
||||
int32_t CMap::s_mapID = -1;
|
||||
char CMap::s_mapName[256];
|
||||
char CMap::s_mapPath[256];
|
||||
char CMap::s_wdtFilename[256];
|
||||
@ -61,7 +62,7 @@ void CMap::Initialize() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CMap::Load(const char* mapName, int32_t zoneID) {
|
||||
void CMap::Load(const char* mapName, int32_t mapID) {
|
||||
// TODO
|
||||
|
||||
auto nameOfs = SStrCopy(CMap::s_mapPath, "World\\Maps\\");
|
||||
@ -72,6 +73,10 @@ void CMap::Load(const char* mapName, int32_t zoneID) {
|
||||
SStrPrintf(CMap::s_wdtFilename, sizeof(CMap::s_wdtFilename), "%s\\%s.wdt", CMap::s_mapPath, CMap::s_mapName);
|
||||
|
||||
// TODO
|
||||
|
||||
CMap::s_mapID = mapID;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CMap::MapMemInitialize() {
|
||||
|
||||
@ -23,6 +23,7 @@ class CMap {
|
||||
static uint32_t* s_mapObjDefHeap;
|
||||
static uint32_t* s_mapObjGroupHeap;
|
||||
static uint32_t* s_mapObjHeap;
|
||||
static int32_t s_mapID;
|
||||
static char s_mapName[];
|
||||
static char s_mapPath[];
|
||||
static char s_wdtFilename[];
|
||||
@ -30,7 +31,7 @@ class CMap {
|
||||
// Static functions
|
||||
static CMapEntity* AllocEntity(int32_t a1);
|
||||
static void Initialize();
|
||||
static void Load(const char* mapName, int32_t zoneID);
|
||||
static void Load(const char* mapName, int32_t mapID);
|
||||
static void MapMemInitialize();
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user