mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-11-26 11:18:16 +00:00
Replace Quaternion with glm math (#1868)
This commit is contained in:
@@ -654,7 +654,7 @@ private:
|
||||
/**
|
||||
* The spawn rotation of this character when loading in
|
||||
*/
|
||||
NiQuaternion m_OriginalRotation;
|
||||
NiQuaternion m_OriginalRotation = QuatUtils::IDENTITY;
|
||||
|
||||
/**
|
||||
* The respawn points of this character, per world
|
||||
|
||||
@@ -304,7 +304,7 @@ void Entity::Initialize() {
|
||||
//If we came from another zone, put us in the starting loc
|
||||
if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||
NiPoint3 pos;
|
||||
NiQuaternion rot;
|
||||
NiQuaternion rot = QuatUtils::IDENTITY;
|
||||
|
||||
const auto& targetSceneName = m_Character->GetTargetScene();
|
||||
auto* targetScene = Game::entityManager->GetSpawnPointEntity(targetSceneName);
|
||||
@@ -1882,7 +1882,7 @@ const NiQuaternion& Entity::GetRotation() const {
|
||||
return rigidBodyPhantomPhysicsComponent->GetRotation();
|
||||
}
|
||||
|
||||
return NiQuaternionConstant::IDENTITY;
|
||||
return QuatUtils::IDENTITY;
|
||||
}
|
||||
|
||||
void Entity::SetPosition(const NiPoint3& position) {
|
||||
@@ -2178,7 +2178,7 @@ const NiPoint3& Entity::GetRespawnPosition() const {
|
||||
|
||||
const NiQuaternion& Entity::GetRespawnRotation() const {
|
||||
auto* characterComponent = GetComponent<CharacterComponent>();
|
||||
return characterComponent ? characterComponent->GetRespawnRotation() : NiQuaternionConstant::IDENTITY;
|
||||
return characterComponent ? characterComponent->GetRespawnRotation() : QuatUtils::IDENTITY;
|
||||
}
|
||||
|
||||
void Entity::SetRespawnPos(const NiPoint3& position) const {
|
||||
|
||||
@@ -357,7 +357,7 @@ private:
|
||||
std::vector<LDFBaseData*> m_NetworkSettings;
|
||||
|
||||
NiPoint3 m_DefaultPosition;
|
||||
NiQuaternion m_DefaultRotation;
|
||||
NiQuaternion m_DefaultRotation = QuatUtils::IDENTITY;
|
||||
float m_Scale;
|
||||
|
||||
Spawner* m_Spawner;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||
Entity* sourceEntity;
|
||||
if (this->m_orientCaster) sourceEntity = Game::entityManager->GetEntity(context->originator);
|
||||
@@ -16,12 +18,12 @@ void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitS
|
||||
if (!destinationEntity) return;
|
||||
|
||||
sourceEntity->SetRotation(
|
||||
NiQuaternion::LookAt(sourceEntity->GetPosition(), destinationEntity->GetPosition())
|
||||
QuatUtils::LookAt(sourceEntity->GetPosition(), destinationEntity->GetPosition())
|
||||
);
|
||||
} else if (this->m_toAngle){
|
||||
auto baseAngle = NiPoint3(0, 0, this->m_angle);
|
||||
if (this->m_relative) baseAngle += sourceEntity->GetRotation().GetForwardVector();
|
||||
sourceEntity->SetRotation(NiQuaternion::FromEulerAngles(baseAngle));
|
||||
if (this->m_relative) baseAngle += QuatUtils::Forward(sourceEntity->GetRotation());
|
||||
sourceEntity->SetRotation(glm::quat(glm::vec3(baseAngle.x, baseAngle.y, baseAngle.z)));
|
||||
} else return;
|
||||
Game::entityManager->SerializeEntity(sourceEntity);
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
|
||||
if (m_Forward == 1) {
|
||||
controllablePhysicsComponent->SetVelocity(controllablePhysicsComponent->GetRotation().GetForwardVector() * 25);
|
||||
controllablePhysicsComponent->SetVelocity(QuatUtils::Forward(controllablePhysicsComponent->GetRotation()) * 25);
|
||||
}
|
||||
|
||||
Game::entityManager->SerializeEntity(casterEntity);
|
||||
|
||||
@@ -92,7 +92,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
|
||||
const auto time = distance / this->m_projectileSpeed;
|
||||
|
||||
const auto rotation = NiQuaternion::LookAtUnlocked(position, other->GetPosition());
|
||||
const auto rotation = QuatUtils::LookAtUnlocked(position, other->GetPosition());
|
||||
|
||||
const auto targetPosition = other->GetPosition();
|
||||
|
||||
@@ -112,13 +112,13 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
|
||||
bitStream.Write(id);
|
||||
|
||||
auto eulerAngles = rotation.GetEulerAngles();
|
||||
auto eulerAngles = QuatUtils::Euler(rotation);
|
||||
|
||||
eulerAngles.y += angle * (3.14 / 180);
|
||||
eulerAngles.y += angle * (glm::pi<float>() / 180.0f);
|
||||
|
||||
const auto angledRotation = NiQuaternion::FromEulerAngles(eulerAngles);
|
||||
const auto angledRotation = QuatUtils::FromEuler(eulerAngles);
|
||||
|
||||
const auto direction = angledRotation.GetForwardVector();
|
||||
const auto direction = QuatUtils::Forward(angledRotation);
|
||||
|
||||
const auto destination = position + direction * distance;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStrea
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = context->originator;
|
||||
info.spawnerNodeID = 0;
|
||||
info.pos = info.pos + (info.rot.GetForwardVector() * m_Distance);
|
||||
info.pos = info.pos + (QuatUtils::Forward(info.rot) * m_Distance);
|
||||
|
||||
auto* entity = Game::entityManager->CreateEntity(
|
||||
info,
|
||||
|
||||
@@ -125,7 +125,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitS
|
||||
if (targetPos.y > reference.y && heightDifference > this->m_upperBound || targetPos.y < reference.y && heightDifference > this->m_lowerBound)
|
||||
continue;
|
||||
|
||||
const auto forward = self->GetRotation().GetForwardVector();
|
||||
const auto forward = QuatUtils::Forward(self->GetRotation());
|
||||
|
||||
// forward is a normalized vector of where the caster is facing.
|
||||
// targetPos is the position of the target.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -33,7 +33,7 @@ struct EntityInfo {
|
||||
LWOOBJID id;
|
||||
LOT lot;
|
||||
NiPoint3 pos;
|
||||
NiQuaternion rot;
|
||||
NiQuaternion rot = QuatUtils::IDENTITY;
|
||||
std::vector<LDFBaseData*> settings;
|
||||
std::vector<LDFBaseData*> networkSettings;
|
||||
float scale;
|
||||
|
||||
@@ -15,11 +15,11 @@ public:
|
||||
iCastType = 0;
|
||||
lastClickedPosit = NiPoint3Constant::ZERO;
|
||||
optionalTargetID = LWOOBJID_EMPTY;
|
||||
originatorRot = NiQuaternionConstant::IDENTITY;
|
||||
originatorRot = QuatUtils::IDENTITY;
|
||||
uiSkillHandle = 0;
|
||||
}
|
||||
|
||||
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = QuatUtils::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||
bUsedMouse = _bUsedMouse;
|
||||
fCasterLatency = _fCasterLatency;
|
||||
iCastType = _iCastType;
|
||||
@@ -58,8 +58,8 @@ public:
|
||||
stream.Write(optionalTargetID != LWOOBJID_EMPTY);
|
||||
if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID);
|
||||
|
||||
stream.Write(originatorRot != NiQuaternionConstant::IDENTITY);
|
||||
if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot);
|
||||
stream.Write(originatorRot != QuatUtils::IDENTITY);
|
||||
if (originatorRot != QuatUtils::IDENTITY) stream.Write(originatorRot);
|
||||
|
||||
uint32_t sBitStreamLength = sBitStream.length();
|
||||
stream.Write(sBitStreamLength);
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
NiPoint3 lastClickedPosit;
|
||||
LWOOBJID optionalOriginatorID;
|
||||
LWOOBJID optionalTargetID;
|
||||
NiQuaternion originatorRot;
|
||||
NiQuaternion originatorRot = QuatUtils::IDENTITY;
|
||||
std::string sBitStream;
|
||||
TSkillID skillID;
|
||||
uint32_t uiSkillHandle;
|
||||
|
||||
@@ -389,7 +389,7 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
|
||||
float fMoveTimeElapsed = 0.0f;
|
||||
float fPercentBetweenPoints = 0.0f;
|
||||
NiPoint3 ptUnexpectedLocation = NiPoint3Constant::ZERO;
|
||||
NiQuaternion qUnexpectedRotation = NiQuaternionConstant::IDENTITY;
|
||||
NiQuaternion qUnexpectedRotation = QuatUtils::IDENTITY;
|
||||
|
||||
bitStream.Write(bReverse);
|
||||
bitStream.Write(bStopAtDesiredWaypoint);
|
||||
@@ -406,8 +406,8 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
|
||||
bitStream.Write(ptUnexpectedLocation.y);
|
||||
bitStream.Write(ptUnexpectedLocation.z);
|
||||
|
||||
bitStream.Write(qUnexpectedRotation != NiQuaternionConstant::IDENTITY);
|
||||
if (qUnexpectedRotation != NiQuaternionConstant::IDENTITY) {
|
||||
bitStream.Write(qUnexpectedRotation != QuatUtils::IDENTITY);
|
||||
if (qUnexpectedRotation != QuatUtils::IDENTITY) {
|
||||
bitStream.Write(qUnexpectedRotation.x);
|
||||
bitStream.Write(qUnexpectedRotation.y);
|
||||
bitStream.Write(qUnexpectedRotation.z);
|
||||
@@ -1181,7 +1181,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
|
||||
bitStream.Write(position.y);
|
||||
bitStream.Write(position.z);
|
||||
|
||||
const bool bIsNotIdentity = rotation != NiQuaternionConstant::IDENTITY;
|
||||
const bool bIsNotIdentity = rotation != QuatUtils::IDENTITY;
|
||||
bitStream.Write(bIsNotIdentity);
|
||||
|
||||
if (bIsNotIdentity) {
|
||||
@@ -2129,8 +2129,8 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress
|
||||
bitStream.Write(response);
|
||||
}
|
||||
|
||||
bitStream.Write(rotation != NiQuaternionConstant::IDENTITY);
|
||||
if (rotation != NiQuaternionConstant::IDENTITY) {
|
||||
bitStream.Write(rotation != QuatUtils::IDENTITY);
|
||||
if (rotation != QuatUtils::IDENTITY) {
|
||||
bitStream.Write(response);
|
||||
}
|
||||
|
||||
@@ -2395,13 +2395,13 @@ void GameMessages::HandlePlacePropertyModel(RakNet::BitStream& inStream, Entity*
|
||||
|
||||
inStream.Read(model);
|
||||
|
||||
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3Constant::ZERO, NiQuaternionConstant::IDENTITY);
|
||||
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3Constant::ZERO, QuatUtils::IDENTITY);
|
||||
}
|
||||
|
||||
void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
LWOOBJID model;
|
||||
NiPoint3 position;
|
||||
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
|
||||
NiQuaternion rotation = QuatUtils::IDENTITY;
|
||||
|
||||
inStream.Read(model);
|
||||
inStream.Read(position);
|
||||
@@ -3400,7 +3400,7 @@ void GameMessages::SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId
|
||||
bitStream.Write(petsDestPos);
|
||||
bitStream.Write(telePos);
|
||||
|
||||
const bool hasDefault = teleRot != NiQuaternionConstant::IDENTITY;
|
||||
const bool hasDefault = teleRot != QuatUtils::IDENTITY;
|
||||
bitStream.Write(hasDefault);
|
||||
if (hasDefault) bitStream.Write(teleRot);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ class AMFBaseValue;
|
||||
class AMFArrayValue;
|
||||
class Entity;
|
||||
class Item;
|
||||
class NiQuaternion;
|
||||
class User;
|
||||
class Leaderboard;
|
||||
class PropertySelectQueryProperty;
|
||||
@@ -765,7 +764,7 @@ namespace GameMessages {
|
||||
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
|
||||
|
||||
NiPoint3 target{};
|
||||
NiQuaternion rotation{};
|
||||
NiQuaternion rotation = QuatUtils::IDENTITY;
|
||||
};
|
||||
|
||||
struct ChildLoaded : public GameMsg {
|
||||
|
||||
@@ -18,11 +18,11 @@ public:
|
||||
iCastType = 0;
|
||||
lastClickedPosit = NiPoint3Constant::ZERO;
|
||||
optionalTargetID = LWOOBJID_EMPTY;
|
||||
originatorRot = NiQuaternionConstant::IDENTITY;
|
||||
originatorRot = QuatUtils::IDENTITY;
|
||||
uiSkillHandle = 0;
|
||||
}
|
||||
|
||||
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = QuatUtils::IDENTITY, uint32_t _uiSkillHandle = 0) {
|
||||
bUsedMouse = _bUsedMouse;
|
||||
consumableItemID = _consumableItemID;
|
||||
fCasterLatency = _fCasterLatency;
|
||||
@@ -65,8 +65,8 @@ public:
|
||||
stream.Write(optionalTargetID != LWOOBJID_EMPTY);
|
||||
if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID);
|
||||
|
||||
stream.Write(originatorRot != NiQuaternionConstant::IDENTITY);
|
||||
if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot);
|
||||
stream.Write(originatorRot != QuatUtils::IDENTITY);
|
||||
if (originatorRot != QuatUtils::IDENTITY) stream.Write(originatorRot);
|
||||
|
||||
uint32_t sBitStreamLength = sBitStream.length();
|
||||
stream.Write(sBitStreamLength);
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
NiPoint3 lastClickedPosit{};
|
||||
LWOOBJID optionalOriginatorID{};
|
||||
LWOOBJID optionalTargetID{};
|
||||
NiQuaternion originatorRot{};
|
||||
NiQuaternion originatorRot = QuatUtils::IDENTITY;
|
||||
std::string sBitStream = "";
|
||||
TSkillID skillID = 0;
|
||||
uint32_t uiSkillHandle = 0;
|
||||
|
||||
@@ -138,7 +138,7 @@ void Strip::Spawn(LOT lot, Entity& entity) {
|
||||
EntityInfo info{};
|
||||
info.lot = lot;
|
||||
info.pos = entity.GetPosition();
|
||||
info.rot = NiQuaternionConstant::IDENTITY;
|
||||
info.rot = QuatUtils::IDENTITY;
|
||||
info.spawnerID = entity.GetObjectID();
|
||||
auto* const spawnedEntity = Game::entityManager->CreateEntity(info, nullptr, &entity);
|
||||
spawnedEntity->AddToGroup("SpawnedPropertyEnemies");
|
||||
|
||||
@@ -649,7 +649,7 @@ namespace DEVGMCommands {
|
||||
if (havokVehiclePhysicsComponent) {
|
||||
havokVehiclePhysicsComponent->SetPosition(pos);
|
||||
Game::entityManager->SerializeEntity(possassableEntity);
|
||||
} else GameMessages::SendTeleport(possassableEntity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
||||
} else GameMessages::SendTeleport(possassableEntity->GetObjectID(), pos, QuatUtils::IDENTITY, sysAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -660,7 +660,7 @@ namespace DEVGMCommands {
|
||||
const auto characters = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
|
||||
|
||||
for (auto* character : characters) {
|
||||
GameMessages::SendTeleport(character->GetObjectID(), pos, NiQuaternion(), character->GetSystemAddress());
|
||||
GameMessages::SendTeleport(character->GetObjectID(), pos, QuatUtils::IDENTITY, character->GetSystemAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ namespace DEVGMCommands {
|
||||
// Set the position to the generated random position plus the player position. This will
|
||||
// spawn the entity in a circle around the player. As you get further from the player, the angle chosen will get less accurate.
|
||||
info.pos = playerPosition + NiPoint3(cos(randomAngle) * randomRadius, 0.0f, sin(randomAngle) * randomRadius);
|
||||
info.rot = NiQuaternion();
|
||||
info.rot = QuatUtils::IDENTITY;
|
||||
|
||||
auto newEntity = Game::entityManager->CreateEntity(info);
|
||||
if (newEntity == nullptr) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
struct VanityObjectLocation {
|
||||
float m_Chance = 1.0f;
|
||||
NiPoint3 m_Position;
|
||||
NiQuaternion m_Rotation;
|
||||
NiQuaternion m_Rotation = QuatUtils::IDENTITY;
|
||||
float m_Scale = 1.0f;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user