-
-
Notifications
You must be signed in to change notification settings - Fork 470
dxDrawModel3D reimplementation #3266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+323
−2
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
435c11c
Add dxDrawModel3D function
tederis 1ab6c5f
Make m_Queue private
tederis 247b37d
Add copyrights
tederis 1ef20fc
Better model enqueueing
tederis a12b341
Merge branch 'master' into dx_draw_model_3d
tederis d4f94f8
Dedicated render path for transparent entities
tederis 6ab0f23
Merge branch 'master' into dx_draw_model_3d
tederis 6437ee4
Remove spaces
tederis f398f2e
Update CLuaDrawingDefs.cpp
tederis 4ef5a66
Update CLuaDrawingDefs.h
tederis 3048472
Merge branch 'master' into dx_draw_model_3d
tederis e2683c5
Merge branch 'master' into dx_draw_model_3d
tederis f24c043
Remove loading scheme
tederis c1b1510
Merge branch 'master' into dx_draw_model_3d
tederis 5a5d289
Additional noexcept
tederis 0482903
Merge branch 'master' into dx_draw_model_3d
TheNormalnij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/CRendererSA.cpp | ||
* PURPOSE: Game renderer class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include "CRendererSA.h" | ||
#include "CModelInfoSA.h" | ||
#include "CMatrix.h" | ||
#include "gamesa_renderware.h" | ||
|
||
CRendererSA::CRendererSA() | ||
{ | ||
} | ||
|
||
CRendererSA::~CRendererSA() | ||
{ | ||
} | ||
|
||
void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) | ||
{ | ||
CBaseModelInfoSAInterface* pModelInfoSAInterface = pModelInfo->GetInterface(); | ||
if (!pModelInfoSAInterface) | ||
return; | ||
|
||
RwObject* pRwObject = pModelInfoSAInterface->pRwObject; | ||
if (!pRwObject) | ||
return; | ||
|
||
RwFrame* pFrame = RpGetFrame(pRwObject); | ||
|
||
static RwMatrix rwMatrix; | ||
rwMatrix.right = (RwV3d&)matrix.vRight; | ||
rwMatrix.up = (RwV3d&)matrix.vFront; | ||
rwMatrix.at = (RwV3d&)matrix.vUp; | ||
rwMatrix.pos = (RwV3d&)matrix.vPos; | ||
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE); | ||
|
||
if (pRwObject->type == RP_TYPE_ATOMIC) | ||
{ | ||
RpAtomic* pRpAtomic = reinterpret_cast<RpAtomic*>(pRwObject); | ||
pRpAtomic->renderCallback(reinterpret_cast<RpAtomic*>(pRwObject)); | ||
} | ||
else | ||
{ | ||
RpClump* pClump = reinterpret_cast<RpClump*>(pRwObject); | ||
RpClumpRender(pClump); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/CRendererSA.h | ||
* PURPOSE: Game renderer class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <game/CRenderer.h> | ||
|
||
class CRendererSA : public CRenderer | ||
{ | ||
public: | ||
CRendererSA(); | ||
~CRendererSA(); | ||
|
||
void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) override; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/deathmatch/logic/CModelRenderer.cpp | ||
* PURPOSE: 3D models renderer | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include "game\CRenderer.h" | ||
#include "game\CVisibilityPlugins.h" | ||
|
||
bool CModelRenderer::EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix) | ||
{ | ||
if (g_pCore->IsWindowMinimized()) | ||
return false; | ||
|
||
if (pModelInfo && pModelInfo->IsLoaded()) | ||
{ | ||
m_Queue.emplace_back(pModelInfo, matrix); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void CModelRenderer::Update() | ||
{ | ||
CVisibilityPlugins* pVisibilityPlugins = g_pGame->GetVisibilityPlugins(); | ||
assert(pVisibilityPlugins); | ||
|
||
for (auto& modelDesc : m_Queue) | ||
{ | ||
// Insert transparent entities into a sorted list | ||
if (modelDesc.pModelInfo->GetIdeFlag(eModelIdeFlag::DRAW_LAST)) | ||
{ | ||
const CVector& vecCameraPosition = *(CVector*)0xB76870; // CRenderer::ms_vecCameraPosition | ||
const float fDistance = (modelDesc.matrix.GetPosition() - vecCameraPosition).Length(); | ||
|
||
pVisibilityPlugins->InsertEntityIntoEntityList(&modelDesc, fDistance, RenderEntity); | ||
} | ||
} | ||
} | ||
|
||
void CModelRenderer::Render() | ||
{ | ||
CRenderer* pRenderer = g_pGame->GetRenderer(); | ||
assert(pRenderer); | ||
|
||
// Draw opaque entities | ||
for (auto& modelDesc : m_Queue) | ||
{ | ||
if (modelDesc.pModelInfo->IsLoaded() && !modelDesc.pModelInfo->GetIdeFlag(eModelIdeFlag::DRAW_LAST)) | ||
pRenderer->RenderModel(modelDesc.pModelInfo, modelDesc.matrix); | ||
} | ||
|
||
m_Queue.clear(); | ||
} | ||
|
||
void CModelRenderer::RenderEntity(SModelToRender* modelDesc, float distance) | ||
{ | ||
if (!modelDesc->pModelInfo->IsLoaded()) | ||
return; | ||
|
||
CRenderer* pRenderer = g_pGame->GetRenderer(); | ||
assert(pRenderer); | ||
|
||
pRenderer->RenderModel(modelDesc->pModelInfo, modelDesc->matrix); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/deathmatch/logic/CModelRenderer.h | ||
* PURPOSE: 3D models renderer | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
class CModelRenderer final | ||
{ | ||
public: | ||
struct SModelToRender final | ||
{ | ||
CModelInfo* pModelInfo; | ||
CMatrix matrix; | ||
|
||
SModelToRender(CModelInfo* pModelInfo, const CMatrix& matrix) : | ||
pModelInfo(pModelInfo), | ||
matrix(matrix) | ||
{ | ||
} | ||
}; | ||
|
||
bool EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix); | ||
|
||
void Update(); | ||
|
||
void Render(); | ||
|
||
static void RenderEntity(SModelToRender* entity, float distance); | ||
|
||
private: | ||
|
||
std::vector<SModelToRender> m_Queue; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.