Compare commits

...

27 Commits

Author SHA1 Message Date
Marco Tylus
9e28841cec
Merge 8935c520c0 into e5150d7d21 2026-03-02 22:16:29 +00:00
fallenoak
e5150d7d21
feat(object): add CGUnit_C::GetFacing
Some checks failed
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Has been cancelled
2026-02-27 20:35:12 -06:00
fallenoak
3a876398a7
feat(object): add CGUnit_C::GetPosition 2026-02-27 20:25:16 -06:00
fallenoak
1b90dcb09b
fix(object): move CMovement_C pointer to proper location in CGUnit 2026-02-27 20:12:08 -06:00
fallenoak
c5bd63b79e
feat(object): add missing CGUnit_C in-class initializers 2026-02-26 07:16:16 -06:00
fallenoak
5492b3f231
feat(object): set position and facing in CGUnit_C ctor
Some checks failed
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Has been cancelled
2026-02-25 22:11:31 -06:00
Tristan 'Natrist' Cormier
8851d2e5e1
feat(glue): implement Script_ScanningAccepted (#160)
Co-authored-by: fallenoak <git@fallenoak.me>
2026-02-25 21:28:59 -06:00
Tristan 'Natrist' Cormier
0a91d44600
feat(glue): implement Script_ContestAccepted (#161)
Co-authored-by: fallenoak <git@fallenoak.me>
2026-02-25 20:36:05 -06:00
Tristan 'Natrist' Cormier
d19658185a
feat(glue): implement Script_TerminationWithoutNoticeAccepted (#159)
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
Co-authored-by: fallenoak <git@fallenoak.me>
2026-02-24 21:00:27 -06:00
Tristan 'Natrist' Cormier
abf2e2cde3
feat(glue): add CGlueMgr::PollCreateCharacter (#167)
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
Co-authored-by: fallenoak <git@fallenoak.me>
2026-02-23 22:30:49 -06:00
Tristan 'Natrist' Cormier
6b7abe3c03
feat(connection): implement character creation message handlers (#166)
Co-authored-by: fallenoak <git@fallenoak.me>
2026-02-23 21:31:12 -06:00
fallenoak
fa98bbc1f0
feat(object): add CGObject_C::GetFacing
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-22 21:57:26 -06:00
fallenoak
af4b798942
feat(ui): call CWorld::Update from CGWorldFrame::OnWorldUpdate
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-21 21:42:41 -06:00
fallenoak
9b18f2f3bd
feat(world): stub CWorld::Update 2026-02-21 21:42:02 -06:00
fallenoak
6cb5310430
feat(object): add CGObject_C::GetPosition 2026-02-21 21:41:37 -06:00
fallenoak
cb8291af1a
feat(ui): add CGCamera::HasModel 2026-02-21 21:41:08 -06:00
fallenoak
58c8975769
feat(ui): add CGCamera::GetTarget 2026-02-21 21:15:01 -06:00
fallenoak
817cec99fe
feat(ui): add CGCamera::Target
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-21 14:11:22 -06:00
fallenoak
6675586a29
feat(ui): add CSimpleCamera::Position 2026-02-21 14:07:33 -06:00
aomizu
8935c520c0 feat: Add texture matrix transform support to Metal shaders for animated textures 2025-12-26 17:03:37 +09:00
aomizu
7cf7127810 feat: Implement color animation in Metal shaders by using diffuse and emissive vertex constants for output color. 2025-12-25 15:11:18 +09:00
aomizu
8fb51991e0 revert: remove non-metal shader init from Client.cpp 2025-12-25 13:24:07 +09:00
aomizu
7fdd22545f feat: Convert GxTex_Argb4444 textures to RGBA8 during Metal upload to simplify handling 2025-12-25 13:10:25 +09:00
aomizu
15eafe92d7 feat: Implement fog and point size in Metal shaders and refine render state processing for textures and other states. 2025-12-25 13:10:25 +09:00
aomizu
1ad3679f90 feat: Implement initial Metal graphics device with comprehensive shader system and pipeline management. 2025-12-25 13:10:25 +09:00
aomizu
81970958a8 feat: Add debug rendering pipeline to draw a triangle in the Metal backend. 2025-12-25 13:10:25 +09:00
aomizu
a9cad5238d init metal backend 2025-12-25 13:10:25 +09:00
42 changed files with 2348 additions and 13 deletions

View File

@ -32,6 +32,8 @@ if(WHOA_SYSTEM_MAC)
"-framework AppKit"
"-framework Carbon"
"-framework IOKit"
"-framework Metal"
"-framework QuartzCore"
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac/MainMenu.nib DESTINATION "bin")

View File

@ -0,0 +1,9 @@
#ifndef APP_MAC_ENGINE_MTL_LAYER_VIEW_H
#define APP_MAC_ENGINE_MTL_LAYER_VIEW_H
#include "app/mac/EngineGLLayerView.h"
@interface EngineMTLLayerView : EngineGLLayerView
@end
#endif

View File

@ -0,0 +1,36 @@
#include "app/mac/EngineMTLLayerView.h"
#import <QuartzCore/CAMetalLayer.h>
@implementation EngineMTLLayerView
- (CALayer*)makeBackingLayer {
return [CAMetalLayer layer];
}
- (id)initWithFrame:(NSRect)frame glWindow:(GLWindow*)window {
self = [super initWithFrame:frame glWindow:window];
if (self) {
[self setWantsLayer:YES];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
// Rendering is driven by CGxDeviceMTL.
}
- (void)update {
[super update];
if (![self.layer isKindOfClass:[CAMetalLayer class]]) {
return;
}
CAMetalLayer* layer = (CAMetalLayer*)self.layer;
CGSize size = [self convertSizeToBacking:self.bounds.size];
layer.drawableSize = size;
}
@end

View File

@ -1,7 +1,9 @@
#include "app/mac/View.h"
#include "app/mac/EngineGLLayerView.h"
#include "app/mac/EngineMTLLayerView.h"
#include "app/mac/WindowCallbacks.h"
#include "gx/gll/GLWindow.h"
#include "gx/Device.hpp"
GLWindowCallbacks EngineViewCallbacks = {
&MacOnResized,
@ -23,5 +25,9 @@ void AssignEngineViewCallbacks(GLWindowCallbacks* callbacks) {
}
Class GetEngineViewClass() {
if (GxDevApi() == GxApi_Metal) {
return [EngineMTLLayerView class];
}
return [EngineGLLayerView class];
}

View File

@ -2,6 +2,7 @@
#include "app/mac/MacClient.h"
#include "event/Input.hpp"
#include "gx/gll/CGxDeviceGLL.hpp"
#include "gx/mtl/CGxDeviceMTL.hpp"
#include "gx/Device.hpp"
#include "gx/Window.hpp"
#include <bc/Debug.hpp>
@ -171,7 +172,11 @@ void MacOnResized(int32_t width, int32_t height, bool a3) {
return;
}
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
if (GxDevApi() == GxApi_GLL) {
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
} else if (GxDevApi() == GxApi_Metal) {
static_cast<CGxDeviceMTL*>(g_theGxDevicePtr)->Resize(width, height);
}
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);

View File

@ -6,6 +6,7 @@
#include "gx/Adapter.hpp"
#include "gx/Device.hpp"
#include <storm/Array.hpp>
#include <cstdlib>
#include <cstring>
static CGxDevice* s_device;
@ -417,6 +418,13 @@ void ConsoleDeviceInitialize(const char* title) {
api = GxApi_GLL;
#endif
#if defined(WHOA_SYSTEM_MAC)
const char* apiOverride = getenv("WHOA_GX_API");
if (apiOverride && !strcmp(apiOverride, "metal")) {
api = GxApi_Metal;
}
#endif
s_device = GxDevCreate(api, OsWindowProc, format);
// TODO

View File

@ -38,7 +38,9 @@
#include <common/MD5.hpp>
#include <cstdio>
int32_t CGlueMgr::m_acceptedContest = 1; // TODO
int32_t CGlueMgr::m_acceptedEULA = 1; // TODO
int32_t CGlueMgr::m_acceptedScanning = 1; // TODO
int32_t CGlueMgr::m_acceptedTerminationWithoutNotice;
int32_t CGlueMgr::m_acceptedTOS = 1; // TODO
int32_t CGlueMgr::m_accountMsgAvailable;
@ -393,6 +395,11 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) {
break;
}
case IDLE_CREATE_CHARACTER: {
CGlueMgr::PollCreateCharacter(msg, complete, result);
break;
}
case IDLE_DELETE_CHARACTER: {
CGlueMgr::PollDeleteCharacter(msg, complete, result);
break;
@ -763,6 +770,37 @@ void CGlueMgr::PollCharacterList(const char* msg, int32_t complete, int32_t resu
}
}
void CGlueMgr::PollCreateCharacter(const char* msg, int32_t complete, int32_t result) {
FrameScript_SignalEvent(UPDATE_STATUS_DIALOG, "%s", msg);
if (CGlueMgr::HandleBattlenetDisconnect()) {
CGlueMgr::SetIdleState(IDLE_NONE);
}
if (!complete) {
return;
}
// Error
if (result == 0) {
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "OKAY", msg);
CGlueMgr::SetIdleState(IDLE_NONE);
return;
}
// Success
CGlueMgr::SetIdleState(IDLE_NONE);
FrameScript_SignalEvent(CLOSE_STATUS_DIALOG, nullptr);
FrameScript_SignalEvent(SELECT_LAST_CHARACTER, nullptr);
CGlueMgr::SetScreen("charselect");
}
void CGlueMgr::PollDeleteCharacter(const char* msg, int32_t complete, int32_t result) {
FrameScript_SignalEvent(UPDATE_STATUS_DIALOG, "%s", msg);

View File

@ -32,7 +32,9 @@ class CGlueMgr {
};
// Static variables
static int32_t m_acceptedContest;
static int32_t m_acceptedEULA;
static int32_t m_acceptedScanning;
static int32_t m_acceptedTerminationWithoutNotice;
static int32_t m_acceptedTOS;
static int32_t m_accountMsgAvailable;
@ -80,6 +82,7 @@ class CGlueMgr {
static int32_t OnKickReasonMsg(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
static void PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op);
static void PollCharacterList(const char* msg, int32_t complete, int32_t result, int32_t errorCode);
static void PollCreateCharacter(const char* msg, int32_t complete, int32_t result);
static void PollDeleteCharacter(const char* msg, int32_t complete, int32_t result);
static void PollEnterWorld();
static void PollLoginServerLogin();

View File

@ -204,7 +204,13 @@ int32_t Script_ShowTerminationWithoutNoticeNotice(lua_State* L) {
}
int32_t Script_TerminationWithoutNoticeAccepted(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (CGlueMgr::m_acceptedTerminationWithoutNotice) {
lua_pushnumber(L, 1.0);
} else {
lua_pushnil(L);
}
return 1;
}
int32_t Script_AcceptTerminationWithoutNotice(lua_State* L) {
@ -216,7 +222,13 @@ int32_t Script_ShowScanningNotice(lua_State* L) {
}
int32_t Script_ScanningAccepted(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (CGlueMgr::m_acceptedScanning) {
lua_pushnumber(L, 1.0);
} else {
lua_pushnil(L);
}
return 1;
}
int32_t Script_AcceptScanning(lua_State* L) {
@ -228,7 +240,13 @@ int32_t Script_ShowContestNotice(lua_State* L) {
}
int32_t Script_ContestAccepted(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (CGlueMgr::m_acceptedContest) {
lua_pushnumber(L, 1.0);
} else {
lua_pushnil(L);
}
return 1;
}
int32_t Script_AcceptContest(lua_State* L) {

View File

@ -18,6 +18,7 @@
#if defined(WHOA_SYSTEM_MAC)
#include "gx/gll/CGxDeviceGLL.hpp"
#include "gx/mtl/CGxDeviceMTL.hpp"
#include "gx/mac/Display.hpp"
#include <ApplicationServices/ApplicationServices.h>
#include <OpenGL/OpenGL.h>
@ -117,6 +118,8 @@ int32_t CGxDevice::AdapterFormats(EGxApi api, TSGrowableArray<CGxFormat>& adapte
CGxDevice::OpenGlAdapterFormats(adapterFormats);
} else if (api == GxApi_GLL) {
CGxDevice::GLLAdapterFormats(adapterFormats);
} else if (api == GxApi_Metal) {
CGxDevice::OpenGlAdapterFormats(adapterFormats);
}
#elif defined(WHOA_SYSTEM_LINUX)
@ -228,6 +231,11 @@ CGxDevice* CGxDevice::NewGLL() {
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0);
return new (m) CGxDeviceGLL();
}
CGxDevice* CGxDevice::NewMTL() {
auto m = SMemAlloc(sizeof(CGxDeviceMTL), __FILE__, __LINE__, 0x0);
return new (m) CGxDeviceMTL();
}
#endif
CGxDevice* CGxDevice::NewOpenGl() {

View File

@ -77,6 +77,7 @@ class CGxDevice {
#endif
#if defined(WHOA_SYSTEM_MAC)
static CGxDevice* NewGLL();
static CGxDevice* NewMTL();
#endif
static CGxDevice* NewOpenGl();
static void OpenGlAdapterFormats(TSGrowableArray<CGxFormat>& adapterFormats);

View File

@ -20,6 +20,7 @@ if(WHOA_SYSTEM_MAC)
file(GLOB MAC_SOURCES
"gll/*.cpp"
"gll/*.mm"
"mtl/*.mm"
"mac/*.cpp"
)

View File

@ -24,6 +24,8 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
device = CGxDevice::NewOpenGl();
} else if (api == GxApi_GLL) {
device = CGxDevice::NewGLL();
} else if (api == GxApi_Metal) {
device = CGxDevice::NewMTL();
} else {
// Error
}

View File

@ -35,7 +35,8 @@ enum EGxApi {
GxApi_D3d10 = 3,
GxApi_D3d11 = 4,
GxApi_GLL = 5,
GxApis_Last = 6
GxApi_Metal = 6,
GxApis_Last = 7
};
enum EGxBlend {

View File

@ -0,0 +1,81 @@
#ifndef GX_MTL_C_GX_DEVICE_MTL_HPP
#define GX_MTL_C_GX_DEVICE_MTL_HPP
#include "gx/CGxDevice.hpp"
#include "gx/gll/GLWindow.h"
class CGxBatch;
class CGxShader;
class CGxDeviceMTL : public CGxDevice {
public:
// Member variables
GLWindow m_window;
// Virtual member functions
void ITexMarkAsUpdated(CGxTex*) override;
void IRsSendToHw(EGxRenderState) override;
int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat&) override;
int32_t DeviceSetFormat(const CGxFormat&) override;
void* DeviceWindow() override;
void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) override {};
void CapsWindowSize(CRect&) override;
void CapsWindowSizeInScreenCoords(CRect& dst) override;
void ScenePresent() override;
void SceneClear(uint32_t, CImVector) override;
void Draw(CGxBatch* batch, int32_t indexed) override;
void PoolSizeSet(CGxPool*, uint32_t) override;
char* BufLock(CGxBuf*) override;
int32_t BufUnlock(CGxBuf*, uint32_t) override;
void BufData(CGxBuf* buf, const void* data, size_t size, uintptr_t offset) override;
void TexDestroy(CGxTex* texId) override;
void IShaderCreate(CGxShader*) override;
void ShaderCreate(CGxShader*[], EGxShTarget, const char*, const char*, int32_t) override;
int32_t StereoEnabled(void) override;
void XformSetProjection(const C44Matrix& matrix) override;
// Member functions
CGxDeviceMTL();
void Resize(uint32_t width, uint32_t height);
private:
void ISetCaps(const CGxFormat& format);
void EnsureLibrary();
void BeginFrame();
void* GetPipeline(EGxVertexBufferFormat format, bool useColor, bool useSkin, bool useTex, int32_t blendMode);
void* GetPoolBuffer(CGxPool* pool);
void ITexCreate(CGxTex* texId);
void ITexUpload(CGxTex* texId);
void* GetTexture(CGxTex* texId);
void* GetSampler(CGxTex* texId);
void EnsureFallbackTexture();
void EnsureDepthTexture(uint32_t width, uint32_t height);
void* GetDepthState(bool depthTest, bool depthWrite, uint32_t depthFunc);
void* m_device = nullptr;
void* m_commandQueue = nullptr;
void* m_layer = nullptr;
void* m_shaderLibrary = nullptr;
void* m_pipelineColor[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolid[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkin[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_frameCommandBuffer = nullptr;
void* m_frameEncoder = nullptr;
void* m_frameDrawable = nullptr;
uint32_t m_frameHasDraw = 0;
uint32_t m_clearMask = 0;
uint32_t m_clearColor = 0;
void* m_fallbackTexture = nullptr;
void* m_fallbackSampler = nullptr;
void* m_depthTexture = nullptr;
uint32_t m_depthWidth = 0;
uint32_t m_depthHeight = 0;
void* m_depthStates[2][2][4] = {};
};
#endif

1855
src/gx/mtl/CGxDeviceMTL.mm Normal file

File diff suppressed because it is too large Load Diff

View File

@ -104,6 +104,10 @@ void ClientConnection::GetRealmList() {
}
}
void ClientConnection::HandleCharacterCreate(uint8_t result) {
this->Complete(result == 47, result);
}
void ClientConnection::HandleCharacterDelete(uint8_t result) {
this->Complete(result == 71, result);
}

View File

@ -22,6 +22,7 @@ class ClientConnection : public RealmConnection {
// Virtual member functions
virtual int32_t HandleConnect();
virtual void HandleCharacterCreate(uint8_t result);
virtual void HandleCharacterDelete(uint8_t result);
// Member functions

View File

@ -20,7 +20,7 @@ int32_t RealmConnection::MessageHandler(void* param, NETMESSAGE msgId, uint32_t
}
case SMSG_CHAR_CREATE: {
// TODO
result = connection->CreateCharHandler(msgId, time, msg);
break;
}
@ -294,6 +294,15 @@ int32_t RealmConnection::HandleCharEnum(uint32_t msgId, uint32_t time, CDataStor
return 1;
}
int32_t RealmConnection::CreateCharHandler(uint32_t msgId, uint32_t time, CDataStore* msg) {
uint8_t result;
msg->Get(result);
this->HandleCharacterCreate(result);
return 1;
}
int32_t RealmConnection::DeleteCharHandler(uint32_t msgId, uint32_t time, CDataStore* msg) {
uint8_t result;
msg->Get(result);

View File

@ -46,12 +46,14 @@ class RealmConnection : public NetClient {
// Virtual member functions
virtual int32_t HandleAuthChallenge(AuthenticationChallenge* challenge);
virtual void HandleCharacterCreate(uint8_t result) = 0;
virtual void HandleCharacterDelete(uint8_t result) = 0;
// Member functions
RealmConnection(RealmResponse* realmResponse);
int32_t HandleAuthResponse(uint32_t msgId, uint32_t time, CDataStore* msg);
int32_t HandleCharEnum(uint32_t msgId, uint32_t time, CDataStore* msg);
int32_t CreateCharHandler(uint32_t msgId, uint32_t time, CDataStore* msg);
int32_t DeleteCharHandler(uint32_t msgId, uint32_t time, CDataStore* msg);
void RequestCharacterEnum();
void RequestCharacterLogin(uint64_t guid, int32_t a2);

View File

@ -95,6 +95,10 @@ void CGObject_C::Disable() {
this->m_disableTimeMs = CWorld::GetCurTimeMs();
}
float CGObject_C::GetFacing() const {
return 0.0f;
}
int32_t CGObject_C::GetModelFileName(const char*& name) const {
return false;
}
@ -103,6 +107,10 @@ CM2Model* CGObject_C::GetObjectModel() {
return this->m_model;
}
C3Vector CGObject_C::GetPosition() const {
return { 0.0f, 0.0f, 0.0f };
}
int32_t CGObject_C::IsInReenable() {
return this->m_inReenable;
}

View File

@ -36,6 +36,10 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
virtual void HandleOutOfRange(OUT_OF_RANGE_TYPE type) {};
virtual void UpdateWorldObject(int32_t a2);
// TODO
virtual C3Vector GetPosition() const;
// TODO
virtual float GetFacing() const;
// TODO
virtual int32_t GetModelFileName(const char*& name) const;
// TODO
virtual int32_t CanHighlight();

View File

@ -1,5 +1,6 @@
#include "object/client/CGUnit.hpp"
#include "object/client/CGObject.hpp"
#include "object/client/CMovement_C.hpp"
uint32_t CGUnit::GetBaseOffset() {
return CGObject::TotalFields();
@ -29,10 +30,18 @@ int32_t CGUnit::GetDisplayID() const {
return this->Unit()->displayID;
}
float CGUnit::GetFacing() const {
return this->m_move->GetFacing();
}
int32_t CGUnit::GetNativeDisplayID() const {
return this->Unit()->nativeDisplayID;
}
C3Vector CGUnit::GetPosition() const {
return this->m_move->GetPosition();
}
CGUnitData* CGUnit::Unit() const {
return this->m_unit;
}

View File

@ -2,8 +2,11 @@
#define OBJECT_CLIENT_CG_UNIT_HPP
#include "util/GUID.hpp"
#include <tempest/Vector.hpp>
#include <cstdint>
class CMovement_C;
struct CGUnitData {
WOWGUID charm;
WOWGUID summon;
@ -83,13 +86,18 @@ class CGUnit {
static uint32_t TotalFieldsSaved();
// Public member functions
CGUnit(CMovement_C& move)
: m_move(&move) {};
int32_t GetDisplayID() const;
float GetFacing() const;
int32_t GetNativeDisplayID() const;
C3Vector GetPosition() const;
protected:
// Protected member variables
CGUnitData* m_unit;
uint32_t* m_unitSaved;
CMovement_C* m_move;
// Protected member functions
CGUnitData* Unit() const;

View File

@ -96,7 +96,11 @@ const char* CGUnit_C::GetDisplayRaceNameFromRecord(const ChrRacesRec* raceRec, U
return raceRec->m_name;
}
CGUnit_C::CGUnit_C(uint32_t time, CClientObjCreate& objCreate) : CGObject_C(time, objCreate) {
CGUnit_C::CGUnit_C(uint32_t time, CClientObjCreate& objCreate)
: CGObject_C(time, objCreate)
, CGUnit(this->m_localMove)
, m_localMove(objCreate.move.status.position28, objCreate.move.status.facing34, this->GetGUID(), this)
{
// TODO
this->RefreshDataPointers();
@ -132,6 +136,10 @@ int32_t CGUnit_C::GetDisplayID() const {
return this->CGUnit::GetDisplayID();
}
float CGUnit_C::GetFacing() const {
return this->CGUnit::GetFacing();
}
int32_t CGUnit_C::GetLocalDisplayID() const {
return this->m_localDisplayID;
}
@ -171,6 +179,10 @@ int32_t CGUnit_C::GetModelFileName(const char*& name) const {
return modelDataRec->m_modelName ? true : false;
}
C3Vector CGUnit_C::GetPosition() const {
return this->CGUnit::GetPosition();
}
void CGUnit_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO

View File

@ -4,6 +4,7 @@
#include "object/client/CClientObjCreate.hpp"
#include "object/client/CGObject_C.hpp"
#include "object/client/CGUnit.hpp"
#include "object/client/CMovement_C.hpp"
#include "object/Types.hpp"
#include "util/GUID.hpp"
@ -27,6 +28,10 @@ class CGUnit_C : public CGObject_C, public CGUnit {
// Virtual public member functions
virtual ~CGUnit_C();
// TODO
virtual C3Vector GetPosition() const;
// TODO
virtual float GetFacing() const;
// TODO
virtual int32_t GetModelFileName(const char*& name) const;
// TODO
virtual int32_t CanHighlight();
@ -49,12 +54,14 @@ class CGUnit_C : public CGObject_C, public CGUnit {
private:
// Private member variables
// TODO
CreatureDisplayInfoRec* m_displayInfo;
CreatureDisplayInfoExtraRec* m_displayInfoExtra;
CreatureModelDataRec* m_modelData;
CreatureSoundDataRec* m_soundData;
CMovement_C m_localMove;
// TODO
UnitBloodLevelsRec* m_bloodRec;
CreatureDisplayInfoRec* m_displayInfo = nullptr;
CreatureDisplayInfoExtraRec* m_displayInfoExtra = nullptr;
CreatureModelDataRec* m_modelData = nullptr;
CreatureSoundDataRec* m_soundData = nullptr;
// TODO
UnitBloodLevelsRec* m_bloodRec = nullptr;
// TODO
int32_t m_localDisplayID = 0;
// TODO

View File

@ -0,0 +1,7 @@
#include "object/client/CMovementData_C.hpp"
CMovementData_C::CMovementData_C(const C3Vector& position, float facing, const WOWGUID& guid, CGUnit_C* unit)
: CMovementShared(0, position, facing, guid)
{
// TODO
}

View File

@ -0,0 +1,14 @@
#ifndef OBJECT_CLIENT_C_MOVEMENT_DATA_C_HPP
#define OBJECT_CLIENT_C_MOVEMENT_DATA_C_HPP
#include "object/movement/CMovementShared.hpp"
class CGUnit_C;
class CMovementData_C : public CMovementShared {
public:
// Public member functions
CMovementData_C(const C3Vector& position, float facing, const WOWGUID& guid, CGUnit_C* unit);
};
#endif

View File

@ -0,0 +1,15 @@
#ifndef OBJECT_CLIENT_C_MOVEMENT_C_HPP
#define OBJECT_CLIENT_C_MOVEMENT_C_HPP
#include "object/client/CMovementData_C.hpp"
#include "util/GUID.hpp"
#include <tempest/Vector.hpp>
class CMovement_C : public CMovementData_C {
public:
// Public member functions
CMovement_C(const C3Vector& position, float facing, const WOWGUID& guid, CGUnit_C* unit)
: CMovementData_C(position, facing, guid, unit) {};
};
#endif

View File

@ -0,0 +1,15 @@
#include "object/movement/CMovementShared.hpp"
CMovementShared::CMovementShared(const WOWGUID& transportGUID, const C3Vector& position, float facing, const WOWGUID& guid)
: CPassenger(transportGUID, position, guid)
{
this->m_facing = facing;
this->m_anchorPosition = position;
this->m_anchorFacing = facing;
this->m_anchorPitch = 0.0f;
this->m_cosAnchorPitch = 1.0f;
this->m_sinAnchorPitch = 0.0f;
this->m_spline = nullptr;
}

View File

@ -0,0 +1,31 @@
#ifndef OBJECT_MOVEMENT_C_MOVEMENT_SHARED_HPP
#define OBJECT_MOVEMENT_C_MOVEMENT_SHARED_HPP
#include "object/movement/CPassenger.hpp"
#include "util/GUID.hpp"
#include <tempest/Vector.hpp>
struct CMoveSpline;
class CMovementShared : public CPassenger {
public:
// Public member functions
CMovementShared(const WOWGUID& transportGUID, const C3Vector& position, float facing, const WOWGUID& guid);
protected:
// Protected member variables
// TODO
C3Vector m_anchorPosition;
float m_anchorFacing;
float m_anchorPitch;
// TODO
C3Vector m_direction;
C2Vector m_direction2d;
float m_cosAnchorPitch;
float m_sinAnchorPitch;
// TODO
CMoveSpline* m_spline;
// TODO
};
#endif

View File

@ -48,7 +48,7 @@ CDataStore& operator>>(CDataStore& msg, CMovementStatus& move) {
msg.Get(move.uint14);
msg.Get(move.uint0);
msg >> move.position18;
msg >> move.position28;
msg.Get(move.facing34);
if (move.moveFlags & 0x200) {

View File

@ -0,0 +1,34 @@
#include "object/movement/CPassenger.hpp"
#include <tempest/Matrix.hpp>
float CPassenger::GetFacing() const {
return this->GetFacing(this->m_facing);
}
float CPassenger::GetFacing(float facing) const {
// If on transport, transform facing by transport facing
if (this->m_transportGUID) {
float transportFacing = 0.0f;
// TODO MovementGetTransportFacing(this->m_transportGUID);
return facing + transportFacing;
}
return facing;
}
C3Vector CPassenger::GetPosition() const {
return this->GetPosition(this->m_position);
}
C3Vector CPassenger::GetPosition(const C3Vector& position) const {
// If on transport, transform position by transport matrix
if (this->m_transportGUID) {
C44Matrix transportMatrix;
// TODO MovementGetTransportMtxX(this->m_transportGUID, &transportMatrix);
return position * transportMatrix;
}
return position;
}

View File

@ -0,0 +1,32 @@
#ifndef OBJECT_MOVEMENT_C_PASSENGER_HPP
#define OBJECT_MOVEMENT_C_PASSENGER_HPP
#include "util/GUID.hpp"
#include <tempest/Vector.hpp>
class CPassenger {
public:
// Public member functions
CPassenger(const WOWGUID& transportGUID, const C3Vector& position, const WOWGUID& guid)
: m_transportGUID(transportGUID)
, m_position(position)
, m_facing(0.0f)
, m_guid(guid) {};
float GetFacing() const;
float GetFacing(float facing) const;
C3Vector GetPosition() const;
C3Vector GetPosition(const C3Vector& position) const;
protected:
// Protected member variables
// TODO
WOWGUID m_transportGUID;
C3Vector m_position;
// TODO
float m_facing;
// TODO
const WOWGUID& m_guid;
// TODO
};
#endif

View File

@ -38,6 +38,9 @@ bool ValidateCameraView(CVar* var, const char* oldValue, const char* value, void
}
CGCamera::CGCamera() : CSimpleCamera(CWorld::GetNearClip(), CWorld::GetFarClip(), 90.0f * CMath::DEG2RAD) {
this->m_model = nullptr;
this->m_target = 0;
this->m_relativeTo = 0;
this->m_view = s_cameraView->GetInt();
@ -63,6 +66,14 @@ C3Vector CGCamera::Forward() const {
return this->CSimpleCamera::Forward();
}
const WOWGUID& CGCamera::GetTarget() const {
return this->m_target;
}
int32_t CGCamera::HasModel() const {
return this->m_model != nullptr;
}
C33Matrix CGCamera::ParentToWorld() const {
// TODO
return {};
@ -80,6 +91,10 @@ void CGCamera::SetupWorldProjection(const CRect& projRect) {
this->SetGxProjectionAndView(projRect);
}
C3Vector CGCamera::Target() const {
return this->m_position + this->Forward();
}
C3Vector CGCamera::Up() const {
if (this->m_relativeTo) {
return this->CSimpleCamera::Up() * this->ParentToWorld();

View File

@ -4,6 +4,8 @@
#include "ui/simple/CSimpleCamera.hpp"
#include "util/GUID.hpp"
class CM2Model;
class CGCamera : public CSimpleCamera {
public:
// Public structs
@ -25,11 +27,17 @@ class CGCamera : public CSimpleCamera {
// Public member functions
CGCamera();
const WOWGUID& GetTarget() const;
int32_t HasModel() const;
C33Matrix ParentToWorld() const;
void SetupWorldProjection(const CRect& projRect);
C3Vector Target() const;
private:
// Private member variables
CM2Model* m_model;
// TODO
WOWGUID m_target;
// TODO
WOWGUID m_relativeTo;
// TODO

View File

@ -2,8 +2,10 @@
#include "gx/Coordinate.hpp"
#include "gx/Shader.hpp"
#include "gx/Transform.hpp"
#include "object/Client.hpp"
#include "ui/game/CGCamera.hpp"
#include "ui/game/PlayerName.hpp"
#include "world/World.hpp"
#include <storm/Memory.hpp>
#include <tempest/Matrix.hpp>
@ -92,7 +94,19 @@ void CGWorldFrame::OnWorldRender() {
void CGWorldFrame::OnWorldUpdate() {
// TODO
auto target = ClntObjMgrObjectPtr(this->m_camera->GetTarget(), TYPE_OBJECT, __FILE__, __LINE__);
// TODO
this->m_camera->SetupWorldProjection(this->m_screenRect);
// TODO
auto targetPos = target && !this->m_camera->HasModel()
? target->GetPosition()
: this->m_camera->Position();
CWorld::Update(this->m_camera->Position(), this->m_camera->Target(), targetPos);
// TODO
}

View File

@ -84,6 +84,10 @@ C3Vector CSimpleCamera::Right() const {
return { this->m_facing.b0, this->m_facing.b1, this->m_facing.b2 };
}
const C3Vector& CSimpleCamera::Position() const {
return this->m_position;
}
void CSimpleCamera::SetFacing(const C3Vector& forward) {
BuildBillboardMatrix(forward, this->m_facing);
}

View File

@ -18,6 +18,7 @@ class CSimpleCamera {
// Public member functions
CSimpleCamera(float nearZ, float farZ, float fov);
CM2Scene* GetScene();
const C3Vector& Position() const;
void SetFacing(const C3Vector& forward);
void SetFacing(const C3Vector& forward, const C3Vector& up);
void SetFacing(float yaw, float pitch, float roll);

View File

@ -213,3 +213,7 @@ void CWorld::SetUpdateTime(float tickTimeSec, uint32_t curTimeMs) {
CWorld::s_tickTimeMs = static_cast<uint32_t>(tickTimeSec * 1000.0f);
CWorld::s_tickTimeSec = tickTimeSec;
}
void CWorld::Update(const C3Vector& cameraPos, const C3Vector& cameraTarget, const C3Vector& targetPos) {
// TODO
}

View File

@ -70,6 +70,7 @@ class CWorld {
static int32_t OnTick(const EVENT_DATA_TICK* data, void* param);
static void SetFarClip(float farClip);
static void SetUpdateTime(float tickTimeSec, uint32_t curTimeMs);
static void Update(const C3Vector& cameraPos, const C3Vector& cameraTarget, const C3Vector& targetPos);
private:
// Private static variables

View File

@ -23,6 +23,8 @@ if(WHOA_SYSTEM_MAC)
"-framework AppKit"
"-framework Carbon"
"-framework IOKit"
"-framework Metal"
"-framework QuartzCore"
)
endif()