mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-10 09:28:06 +00:00
Replace Quaternion with glm math (#1868)
This commit is contained in:
@@ -767,7 +767,7 @@ void BaseCombatAIComponent::LookAt(const NiPoint3& point) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_Parent->SetRotation(NiQuaternion::LookAt(m_Parent->GetPosition(), point));
|
||||
m_Parent->SetRotation(QuatUtils::LookAt(m_Parent->GetPosition(), point));
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::SetDisabled(bool value) {
|
||||
|
@@ -77,4 +77,4 @@ target_include_directories(dComponents PUBLIC "."
|
||||
)
|
||||
target_precompile_headers(dComponents REUSE_FROM dGameBase)
|
||||
|
||||
target_link_libraries(dComponents INTERFACE dBehaviors)
|
||||
target_link_libraries(dComponents INTERFACE dBehaviors PRIVATE glm::glm)
|
||||
|
@@ -622,7 +622,7 @@ private:
|
||||
|
||||
NiPoint3 m_respawnPos;
|
||||
|
||||
NiQuaternion m_respawnRot;
|
||||
NiQuaternion m_respawnRot = QuatUtils::IDENTITY;
|
||||
|
||||
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
||||
|
||||
|
@@ -1279,7 +1279,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
EntityInfo info{};
|
||||
info.lot = item->GetLot();
|
||||
info.pos = m_Parent->GetPosition();
|
||||
info.rot = NiQuaternionConstant::IDENTITY;
|
||||
info.rot = QuatUtils::IDENTITY;
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* pet = Game::entityManager->CreateEntity(info);
|
||||
|
@@ -198,7 +198,7 @@ private:
|
||||
/**
|
||||
* The rotation original of the model
|
||||
*/
|
||||
NiQuaternion m_OriginalRotation;
|
||||
NiQuaternion m_OriginalRotation = QuatUtils::IDENTITY;
|
||||
|
||||
/**
|
||||
* The ID of the user that made the model
|
||||
|
@@ -83,7 +83,7 @@ void MovementAIComponent::Resume() {
|
||||
m_Paused = false;
|
||||
SetVelocity(m_SavedVelocity);
|
||||
m_SavedVelocity = NiPoint3Constant::ZERO;
|
||||
SetRotation(NiQuaternion::LookAt(m_Parent->GetPosition(), m_NextWaypoint));
|
||||
SetRotation(QuatUtils::LookAt(m_Parent->GetPosition(), m_NextWaypoint));
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
m_TimeTravelled = 0.0f;
|
||||
m_TimeToTravel = length / speed;
|
||||
|
||||
SetRotation(NiQuaternion::LookAt(source, m_NextWaypoint));
|
||||
SetRotation(QuatUtils::LookAt(source, m_NextWaypoint));
|
||||
}
|
||||
} else {
|
||||
// Check if there are more waypoints in the queue, if so set our next destination to the next waypoint
|
||||
|
@@ -168,7 +168,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
const auto originatorPosition = originator->GetPosition();
|
||||
|
||||
m_Parent->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition));
|
||||
m_Parent->SetRotation(QuatUtils::LookAt(petPosition, originatorPosition));
|
||||
|
||||
float interactionDistance = m_Parent->GetVar<float>(u"interaction_distance");
|
||||
if (interactionDistance <= 0) {
|
||||
@@ -177,7 +177,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
auto position = originatorPosition;
|
||||
|
||||
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||
NiPoint3 forward = QuatUtils::Forward(QuatUtils::LookAt(m_Parent->GetPosition(), originator->GetPosition()));
|
||||
forward.y = 0;
|
||||
|
||||
if (dpWorld::IsLoaded()) {
|
||||
@@ -186,7 +186,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
NiPoint3 nearestPoint = dpWorld::GetNavMesh()->NearestPoint(attempt);
|
||||
|
||||
while (std::abs(nearestPoint.y - petPosition.y) > 4 && interactionDistance > 10) {
|
||||
const NiPoint3 forward = m_Parent->GetRotation().GetForwardVector();
|
||||
const NiPoint3 forward = QuatUtils::Forward(m_Parent->GetRotation());
|
||||
|
||||
attempt = originatorPosition + forward * interactionDistance;
|
||||
|
||||
@@ -200,7 +200,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
position = petPosition + forward * interactionDistance;
|
||||
}
|
||||
|
||||
auto rotation = NiQuaternion::LookAt(position, petPosition);
|
||||
auto rotation = QuatUtils::LookAt(position, petPosition);
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
originator->GetObjectID(),
|
||||
@@ -460,7 +460,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
EntityInfo info{};
|
||||
info.lot = entry->puzzleModelLot;
|
||||
info.pos = position;
|
||||
info.rot = NiQuaternionConstant::IDENTITY;
|
||||
info.rot = QuatUtils::IDENTITY;
|
||||
info.spawnerID = tamer->GetObjectID();
|
||||
|
||||
auto* modelEntity = Game::entityManager->CreateEntity(info);
|
||||
@@ -522,7 +522,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
ePetTamingNotifyType::NAMINGPET,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiQuaternionConstant::IDENTITY,
|
||||
QuatUtils::IDENTITY,
|
||||
UNASSIGNED_SYSTEM_ADDRESS
|
||||
);
|
||||
|
||||
@@ -601,7 +601,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
ePetTamingNotifyType::SUCCESS,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiQuaternionConstant::IDENTITY,
|
||||
QuatUtils::IDENTITY,
|
||||
UNASSIGNED_SYSTEM_ADDRESS
|
||||
);
|
||||
|
||||
@@ -645,7 +645,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
ePetTamingNotifyType::QUIT,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiQuaternionConstant::IDENTITY,
|
||||
QuatUtils::IDENTITY,
|
||||
UNASSIGNED_SYSTEM_ADDRESS
|
||||
);
|
||||
|
||||
@@ -696,7 +696,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
ePetTamingNotifyType::FAILED,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiPoint3Constant::ZERO,
|
||||
NiQuaternionConstant::IDENTITY,
|
||||
QuatUtils::IDENTITY,
|
||||
UNASSIGNED_SYSTEM_ADDRESS
|
||||
);
|
||||
|
||||
|
@@ -175,5 +175,5 @@ private:
|
||||
/**
|
||||
* If this is a respawn volume, the exact rotation an entity will respawn
|
||||
*/
|
||||
NiQuaternion m_RespawnRot;
|
||||
NiQuaternion m_RespawnRot = QuatUtils::IDENTITY;
|
||||
};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
PhysicsComponent::PhysicsComponent(Entity* parent, int32_t componentId) : Component(parent) {
|
||||
m_Position = NiPoint3Constant::ZERO;
|
||||
m_Rotation = NiQuaternionConstant::IDENTITY;
|
||||
m_Rotation = QuatUtils::IDENTITY;
|
||||
m_DirtyPosition = false;
|
||||
|
||||
CDPhysicsComponentTable* physicsComponentTable = CDClientManager::GetTable<CDPhysicsComponentTable>();
|
||||
@@ -81,10 +81,10 @@ dpEntity* PhysicsComponent::CreatePhysicsEntity(eReplicaComponentType type) {
|
||||
toReturn = new dpEntity(m_Parent->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
||||
toReturn = new dpEntity(m_Parent->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
||||
m_Position += m_Rotation.GetForwardVector() * 7.5f;
|
||||
m_Position += QuatUtils::Forward(m_Rotation) * 7.5f;
|
||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
||||
toReturn = new dpEntity(m_Parent->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
||||
m_Position += m_Rotation.GetForwardVector() * 6.0f;
|
||||
m_Position += QuatUtils::Forward(m_Rotation) * 6.0f;
|
||||
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
||||
toReturn = new dpEntity(m_Parent->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
||||
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
||||
|
@@ -45,7 +45,7 @@ protected:
|
||||
|
||||
NiPoint3 m_Position;
|
||||
|
||||
NiQuaternion m_Rotation;
|
||||
NiQuaternion m_Rotation = QuatUtils::IDENTITY;
|
||||
|
||||
bool m_DirtyPosition;
|
||||
|
||||
|
@@ -333,7 +333,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
|
||||
const auto modelLOT = item->GetLot();
|
||||
|
||||
if (rotation != NiQuaternionConstant::IDENTITY) {
|
||||
if (rotation != QuatUtils::IDENTITY) {
|
||||
rotation = { rotation.w, rotation.z, rotation.y, rotation.x };
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, QuatUtils::IDENTITY);
|
||||
|
||||
if (spawner != nullptr) {
|
||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
@@ -569,7 +569,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, NiQuaternionConstant::IDENTITY);
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 16, QuatUtils::IDENTITY);
|
||||
|
||||
if (spawner != nullptr) {
|
||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
|
@@ -123,7 +123,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
auto spawnPointEntities = Game::entityManager->GetEntitiesByLOT(4843);
|
||||
auto startPosition = NiPoint3Constant::ZERO;
|
||||
auto startRotation = NiQuaternionConstant::IDENTITY;
|
||||
auto startRotation = QuatUtils::IDENTITY;
|
||||
const std::string placementAsString = std::to_string(positionNumber);
|
||||
for (auto entity : spawnPointEntities) {
|
||||
if (!entity) continue;
|
||||
|
@@ -48,7 +48,7 @@ struct RacingPlayerInfo {
|
||||
/**
|
||||
* Rotation that the player will respawn at if they smash their car
|
||||
*/
|
||||
NiQuaternion respawnRotation;
|
||||
NiQuaternion respawnRotation = QuatUtils::IDENTITY;
|
||||
|
||||
/**
|
||||
* The index in the respawn point the player is now at
|
||||
|
@@ -316,7 +316,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(
|
||||
start.originatorRot = originator->GetRotation();
|
||||
}
|
||||
|
||||
if (rotationOverride != NiQuaternionConstant::IDENTITY) {
|
||||
if (rotationOverride != QuatUtils::IDENTITY) {
|
||||
start.originatorRot = rotationOverride;
|
||||
}
|
||||
//start.optionalTargetID = target;
|
||||
|
@@ -129,7 +129,7 @@ public:
|
||||
* @param optionalOriginatorID change the originator of the skill
|
||||
* @return if the case succeeded
|
||||
*/
|
||||
bool CastSkill(const uint32_t skillId, LWOOBJID target = LWOOBJID_EMPTY, const LWOOBJID optionalOriginatorID = LWOOBJID_EMPTY, const int32_t castType = 0, const NiQuaternion rotationOverride = NiQuaternionConstant::IDENTITY);
|
||||
bool CastSkill(const uint32_t skillId, LWOOBJID target = LWOOBJID_EMPTY, const LWOOBJID optionalOriginatorID = LWOOBJID_EMPTY, const int32_t castType = 0, const NiQuaternion rotationOverride = QuatUtils::IDENTITY);
|
||||
|
||||
/**
|
||||
* Initializes a server-side skill calculation.
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
* @param originatorOverride an override for the originator of the skill calculation
|
||||
* @return the result of the skill calculation
|
||||
*/
|
||||
SkillExecutionResult CalculateBehavior(uint32_t skillId, uint32_t behaviorId, LWOOBJID target, bool ignoreTarget = false, bool clientInitalized = false, LWOOBJID originatorOverride = LWOOBJID_EMPTY, const int32_t castType = 0, const NiQuaternion rotationOverride = NiQuaternionConstant::IDENTITY);
|
||||
SkillExecutionResult CalculateBehavior(uint32_t skillId, uint32_t behaviorId, LWOOBJID target, bool ignoreTarget = false, bool clientInitalized = false, LWOOBJID originatorOverride = LWOOBJID_EMPTY, const int32_t castType = 0, const NiQuaternion rotationOverride = QuatUtils::IDENTITY);
|
||||
|
||||
/**
|
||||
* Register a server-side projectile.
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "EntityManager.h"
|
||||
#include "MovementAIComponent.h"
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo) : Component(parent) {
|
||||
m_Parent = parent;
|
||||
m_Trigger = nullptr;
|
||||
@@ -240,10 +242,9 @@ void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::s
|
||||
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
if (argArray.size() <= 2) return;
|
||||
|
||||
const NiPoint3 vector = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
||||
const auto vector = GeneralUtils::TryParse<glm::vec3>(argArray).value_or(glm::zero<glm::vec3>());
|
||||
|
||||
NiQuaternion rotation = NiQuaternion::FromEulerAngles(vector);
|
||||
targetEntity->SetRotation(rotation);
|
||||
targetEntity->SetRotation(glm::quat(vector));
|
||||
}
|
||||
|
||||
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
|
Reference in New Issue
Block a user