Switch to Vec3fp and fp variables for character
This commit is contained in:
1 parent
8df016c0a4
commit
889c6d465b
23 files changed
+384
-406
No files matched your search
+25
-30
@@ -61,6 +61,9 @@ public:
|
||||
// Distance below which the character is considered to have reached its target.
|
||||
static constexpr float kWalkThreshold = 0.05f;
|
||||
|
||||
static fp kWalkThreshold_SQUARED() { return static_cast<fp>(kWalkThreshold * kWalkThreshold); };
|
||||
|
||||
|
||||
// --- Identity ---
|
||||
std::string npcName;
|
||||
bool isPlayer = false;
|
||||
@@ -68,15 +71,15 @@ public:
|
||||
bool canAttack = false;
|
||||
|
||||
// --- Position / orientation ---
|
||||
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
||||
float facingAngle = 0.0f;
|
||||
float targetFacingAngle = 0.0f;
|
||||
Vec3fp position;
|
||||
fp facingAngle;
|
||||
fp targetFacingAngle;
|
||||
|
||||
// --- Health ---
|
||||
float hp = 200.f;
|
||||
float initialHp = 200.f;
|
||||
|
||||
float visibleRange = VISIBLE_RANGE;
|
||||
fp visibleRange = static_cast<fp>(VISIBLE_RANGE);
|
||||
|
||||
// --- Combat flags ---
|
||||
int battle_state = 0;
|
||||
@@ -95,8 +98,8 @@ public:
|
||||
std::string faceTargetId;
|
||||
|
||||
// --- Home position for drift recovery ---
|
||||
Eigen::Vector3f homePosition = Eigen::Vector3f::Zero();
|
||||
float maxHomeDrift = 3.0f;
|
||||
Vec3fp homePosition;
|
||||
fp maxHomeDriftSquared = static_cast<fp>(3.f*3.f);
|
||||
|
||||
// --- Authoritative logical animation clock ---
|
||||
// Frame counts are immutable metadata copied from loaded clips during
|
||||
@@ -106,26 +109,27 @@ public:
|
||||
std::array<int, 9> animationFrameCounts = {{1, 1, 1, 1, 1, 1, 1, 1, 1}};
|
||||
|
||||
// --- Movement / visual parameters ---
|
||||
float walkSpeed = 3.0f;
|
||||
float rotationSpeed = 4.0f;
|
||||
fp walkSpeed = static_cast<fp>(3.0f);
|
||||
fp rotationSpeed = static_cast<fp>(4.0f);
|
||||
|
||||
float modelScale = 0.12f;
|
||||
Eigen::Quaternionf modelCorrectionRotation = Eigen::Quaternionf::Identity();
|
||||
bool useGpuSkinning = true;
|
||||
// Full clearance used while planning around stationary characters.
|
||||
float collisionRadius = 0.45f;
|
||||
//fp collisionRadius = static_cast<fp>(0.45f);
|
||||
// Smaller physical contact threshold used by the movement guard.
|
||||
float movementContactRadius = 0.32f;
|
||||
float interactionRadius = 0.0f;
|
||||
//fp movementContactRadius = static_cast<fp>(0.32f);
|
||||
fp interactionRadius = static_cast<fp>(0.0f);
|
||||
bool movedLastTick = false;
|
||||
|
||||
// --- Pathfinding data (serializable parts) ---
|
||||
Eigen::Vector3f walkTarget = Eigen::Vector3f::Zero();
|
||||
Eigen::Vector3f requestedWalkTarget = Eigen::Vector3f::Zero();
|
||||
std::vector<Eigen::Vector3f> pathWaypoints;
|
||||
Vec3fp walkTarget;
|
||||
Vec3fp requestedWalkTarget;
|
||||
std::vector<Vec3fp> pathWaypoints;
|
||||
size_t currentWaypointIndex = 0;
|
||||
|
||||
// Internal drift-check timer (serializable so it survives save/load).
|
||||
float homeDriftCheckTimer = 5.0f;
|
||||
fp homeDriftCheckTimer = static_cast<fp>(5.0f);
|
||||
int movementBlockedTicks = 0;
|
||||
int navigationRetryTicks = 0;
|
||||
std::string blockingCharacterId;
|
||||
@@ -145,10 +149,10 @@ public:
|
||||
const std::string& entityId,
|
||||
std::vector<int> cooldownTicks = {});
|
||||
bool isMoving() const;
|
||||
const Eigen::Vector3f& getRequestedWalkTarget() const { return requestedWalkTarget; }
|
||||
Eigen::Vector3f getCurrentNavigationTarget() const;
|
||||
const Vec3fp& getRequestedWalkTarget() const { return requestedWalkTarget; }
|
||||
Vec3fp getCurrentNavigationTarget() const;
|
||||
void stopInPlace();
|
||||
void setTarget(const Eigen::Vector3f& target,
|
||||
void setTarget(const Vec3fp& target,
|
||||
std::string callbackName,
|
||||
const LocationNetworkState& location,
|
||||
const std::string& entityId);
|
||||
@@ -173,23 +177,14 @@ using PlayerStateMap =
|
||||
std::unordered_map<std::string, std::shared_ptr<CharacterState>>;
|
||||
|
||||
struct CharacterObservation {
|
||||
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
||||
Vec3fp position;
|
||||
float hp = 0.f;
|
||||
};
|
||||
|
||||
struct CharacterMovementObstacle {
|
||||
std::string id;
|
||||
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
||||
float radius = 0.f;
|
||||
bool moving = false;
|
||||
Eigen::Vector3f movementDirection = Eigen::Vector3f::Zero();
|
||||
};
|
||||
|
||||
struct CharacterUpdateContext {
|
||||
std::string characterId;
|
||||
const CharacterObservation* attackTarget = nullptr;
|
||||
const CharacterObservation* faceTarget = nullptr;
|
||||
const std::vector<CharacterMovementObstacle>* movementObstacles = nullptr;
|
||||
};
|
||||
|
||||
struct CharacterUpdateEvents {
|
||||
@@ -197,11 +192,11 @@ struct CharacterUpdateEvents {
|
||||
bool deathAnimationComplete = false;
|
||||
bool navigationRequested = false;
|
||||
bool forceNavigationReplan = false;
|
||||
Eigen::Vector3f navigationTarget = Eigen::Vector3f::Zero();
|
||||
Vec3fp navigationTarget;
|
||||
std::string blockingCharacterId;
|
||||
std::string arrivedCallbackName;
|
||||
std::string attackTargetId;
|
||||
Eigen::Vector3f attackDirection = Eigen::Vector3f::Zero();
|
||||
Vec3fp attackDirection;
|
||||
};
|
||||
|
||||
} // namespace FRG
|
||||
Reference in new issue
Block a user