-
-
Notifications
You must be signed in to change notification settings - Fork 491
Extract SA interfaces to separate files #1 (C3DMarkerSAInterface) #4063
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
Open
FileEX
wants to merge
4
commits into
multitheftauto:master
Choose a base branch
from
FileEX:refactor/interfaces_cleanup_3dMarker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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
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,48 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/interfaces/C3DMarkerSAInterface.cpp | ||
* PURPOSE: 3D Marker game layer interface | ||
* | ||
* Multi Theft Auto is available from https://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
#include "StdInc.h" | ||
#include "C3DMarkerSAInterface.h" | ||
|
||
bool C3DMarkerSAInterface::AddMarker(std::uint32_t id, e3DMarkerType type, float size, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint16_t pulsePeriod, float pulseFraction, std::int16_t rotateRate) | ||
{ | ||
return ((bool(__thiscall*)(C3DMarkerSAInterface*, std::uint32_t, std::uint16_t, float, std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t, std::uint16_t, float, std::int16_t))0x722230)(this, id, static_cast<std::uint16_t>(type), size, r, g, b, a, pulsePeriod, pulseFraction, rotateRate); | ||
} | ||
|
||
void C3DMarkerSAInterface::DeleteMarkerObject() | ||
{ | ||
((void(__thiscall*)(C3DMarkerSAInterface*))0x722390)(this); | ||
} | ||
|
||
bool C3DMarkerSAInterface::IsZCoordinateUpToDate() const | ||
{ | ||
const CVector& pos = m_mat.GetPosition(); | ||
return m_LastMapReadX == static_cast<std::uint16_t>(pos.fX) && m_LastMapReadY == static_cast<std::uint16_t>(pos.fY); | ||
} | ||
|
||
void C3DMarkerSAInterface::SetZCoordinateIfNotUpToDate(float newZPos) | ||
{ | ||
if (!IsZCoordinateUpToDate()) | ||
{ | ||
CVector& pos = m_mat.GetPosition(); | ||
pos.fZ = newZPos; | ||
} | ||
} | ||
|
||
void C3DMarkerSAInterface::UpdateZCoordinate(CVector point, float zDistance) | ||
{ | ||
((void(__thiscall*)(C3DMarkerSAInterface*, CVector, float))0x724D40)(this, point, zDistance); | ||
} | ||
|
||
void C3DMarkerSAInterface::DeleteIfHasAtomic() | ||
{ | ||
if (m_pRwObject) | ||
DeleteMarkerObject(); | ||
} |
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,57 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/interfaces/C3DMarkerSAInterface.h | ||
* PURPOSE: Header file for 3D Marker game layer interface | ||
* | ||
* Multi Theft Auto is available from https://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <game/C3DMarker.h> | ||
#include "game/RenderWare.h" | ||
#include "../CMatrixSA.h" | ||
|
||
class C3DMarkerSAInterface | ||
{ | ||
public: | ||
CMatrixSAInterface m_mat; // local space to world space transform | ||
RpAtomic* m_pRwObject; | ||
RpMaterial* m_pMaterial; | ||
std::uint16_t m_nType; // e3DMarkerType | ||
bool m_bIsUsed; // has this marker been allocated this frame? | ||
bool m_mustBeRenderedThisFrame; | ||
std::uint32_t m_nIdentifier; | ||
RwColor rwColour; | ||
std::uint16_t m_nPulsePeriod; | ||
std::int16_t m_nRotateRate; // deg per frame (in either direction) | ||
std::uint32_t m_nStartTime; | ||
float m_fPulseFraction; | ||
float m_fStdSize; | ||
float m_fSize; | ||
float m_fBrightness; | ||
float m_fCameraRange; | ||
CVector m_normal; // Normal of the object point at | ||
|
||
// The following variables remember the last time we read the height of the map. | ||
// Using this we don't have to do this every frame and we can still have moving markers. | ||
std::uint16_t m_LastMapReadX; | ||
std::uint16_t m_LastMapReadY; | ||
float m_LastMapReadResultZ; | ||
float m_roofHeight; | ||
CVector m_lastPosition; | ||
std::uint32_t m_OnScreenTestTime; // time last screen check was done | ||
|
||
public: | ||
inline bool AddMarker(std::uint32_t id, e3DMarkerType type, float size, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint16_t pulsePeriod, | ||
float pulseFraction, std::int16_t rotateRate); | ||
inline void DeleteMarkerObject(); | ||
inline bool IsZCoordinateUpToDate() const; | ||
inline void SetZCoordinateIfNotUpToDate(float newZPos); | ||
inline void UpdateZCoordinate(CVector point, float zDistance); | ||
inline void DeleteIfHasAtomic(); | ||
}; | ||
static_assert(sizeof(C3DMarkerSAInterface) == 0xA0, "Invalid size for C3DMarkerSAInterface"); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is interesting, but i think there were some sort of design choices involved. So we store SA interfaces and wrappers in the same file.
What do the other contributors think about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tederis @botder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that generally the separation of MTA wrappers and SA internal structures is reasonable. I don't think that this can harm the existed code in any way.