Added collision

This commit is contained in:
anime committed 2026-04-26 22:18:42 +06:00
1 parent 2ee288cbe0
commit cebbb8bb5d
6 files changed
+465 -21

No files matched your search

+37
View File
@@ -78,6 +78,43 @@ void Character::setPathPlanner(PathPlanner planner) {
pathPlanner = std::move(planner);
}
bool Character::isMoving() const
{
Eigen::Vector3f toTarget = walkTarget - position;
toTarget.y() = 0.f;
return !pathWaypoints.empty() || toTarget.norm() > WALK_THRESHOLD;
}
Eigen::Vector3f Character::getCurrentNavigationTarget() const
{
if (!pathWaypoints.empty() && currentWaypointIndex < pathWaypoints.size()) {
return pathWaypoints[currentWaypointIndex];
}
return walkTarget;
}
void Character::forceReplan()
{
if (!pathPlanner) {
return;
}
const Eigen::Vector3f normalizedTarget(requestedWalkTarget.x(), 0.f, requestedWalkTarget.z());
pathWaypoints = pathPlanner(position, normalizedTarget);
currentWaypointIndex = 0;
if (!pathWaypoints.empty()) {
for (Eigen::Vector3f& waypoint : pathWaypoints) {
waypoint.y() = 0.f;
}
walkTarget = pathWaypoints.back();
return;
}
walkTarget = Eigen::Vector3f(position.x(), 0.f, position.z());
onArrivedCallback = nullptr;
}
void Character::setTexture(std::shared_ptr<ZL::Texture> texture)
{
for (auto& animEntry : animations) {