이대로 제출해버릴까..
This commit is contained in:
@@ -146,7 +146,7 @@ void Engine::Update() {
|
||||
vulkan_graphics->RenderModel(it.second);
|
||||
}
|
||||
|
||||
Physics::invokeOnColisionEvent(thread_pool_, models_);
|
||||
// Physics::invokeOnColisionEvent(thread_pool_, models_);
|
||||
|
||||
vulkan_graphics->EndFrame();
|
||||
}
|
||||
@@ -187,38 +187,90 @@ float GetAlpha(double old_time, double new_time) {
|
||||
|
||||
void Interpolation(Packet::Header header, std::shared_ptr<veng::Model> local,
|
||||
std::shared_ptr<veng::Model> remote) {
|
||||
constexpr float position_threshold = 5.0f; // 위치 차이 임계값
|
||||
constexpr float rotation_threshold = 0.5f; // 회전 차이 임계값 (라디안 기준)
|
||||
|
||||
std::lock_guard lock(local->modding);
|
||||
local->position =
|
||||
glm::mix(local->position, remote->position,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
local->linear_velocity =
|
||||
glm::mix(local->linear_velocity, remote->linear_velocity,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
float alpha = GetAlpha(local->lastUpdatedTime, header.timestamp);
|
||||
|
||||
// 위치 보간 또는 강제 이동
|
||||
if (glm::distance(local->position, remote->position) > position_threshold) {
|
||||
local->position = remote->position;
|
||||
} else {
|
||||
local->position = glm::mix(local->position, remote->position, alpha);
|
||||
}
|
||||
|
||||
// 선속도
|
||||
if (glm::length(remote->linear_velocity - local->linear_velocity) >
|
||||
position_threshold) {
|
||||
local->linear_velocity = remote->linear_velocity;
|
||||
} else {
|
||||
local->linear_velocity =
|
||||
glm::mix(local->linear_velocity, remote->linear_velocity, alpha);
|
||||
}
|
||||
|
||||
local->linear_acceleration =
|
||||
glm::mix(local->linear_acceleration, remote->linear_acceleration,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
glm::mix(local->linear_acceleration, remote->linear_acceleration, alpha);
|
||||
|
||||
// 회전 보간 또는 강제 이동
|
||||
if (glm::length(remote->rotation - local->rotation) > rotation_threshold) {
|
||||
local->rotation = remote->rotation;
|
||||
} else {
|
||||
local->rotation = glm::mix(local->rotation, remote->rotation, alpha);
|
||||
}
|
||||
|
||||
local->rotation =
|
||||
glm::mix(local->rotation, remote->rotation,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
local->angular_velocity =
|
||||
glm::mix(local->angular_velocity, remote->angular_velocity,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
local->angular_acceleration =
|
||||
glm::mix(local->angular_acceleration, remote->angular_acceleration,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
glm::mix(local->angular_velocity, remote->angular_velocity, alpha);
|
||||
|
||||
local->scale = glm::mix(local->scale, remote->scale,
|
||||
GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
local->angular_acceleration = glm::mix(local->angular_acceleration,
|
||||
remote->angular_acceleration, alpha);
|
||||
|
||||
// 스케일은 보간만 적용
|
||||
local->scale = glm::mix(local->scale, remote->scale, alpha);
|
||||
|
||||
// 동기화 항목은 그대로 적용
|
||||
local->original_offset = remote->original_offset;
|
||||
local->radius = remote->radius;
|
||||
local->lifespan = remote->lifespan;
|
||||
|
||||
local->visible = remote->visible;
|
||||
local->colision = remote->colision;
|
||||
}
|
||||
|
||||
|
||||
//void Interpolation(Packet::Header header, std::shared_ptr<veng::Model> local,
|
||||
// std::shared_ptr<veng::Model> remote) {
|
||||
// std::lock_guard lock(local->modding);
|
||||
// local->position =
|
||||
// glm::mix(local->position, remote->position,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
// local->linear_velocity =
|
||||
// glm::mix(local->linear_velocity, remote->linear_velocity,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
// local->linear_acceleration =
|
||||
// glm::mix(local->linear_acceleration, remote->linear_acceleration,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
//
|
||||
// local->rotation =
|
||||
// glm::mix(local->rotation, remote->rotation,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
// local->angular_velocity =
|
||||
// glm::mix(local->angular_velocity, remote->angular_velocity,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
// local->angular_acceleration =
|
||||
// glm::mix(local->angular_acceleration, remote->angular_acceleration,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
//
|
||||
// local->scale = glm::mix(local->scale, remote->scale,
|
||||
// GetAlpha(local->lastUpdatedTime, header.timestamp));
|
||||
//
|
||||
// local->original_offset = remote->original_offset;
|
||||
// local->radius = remote->radius;
|
||||
// local->lifespan = remote->lifespan;
|
||||
//
|
||||
// local->visible = remote->visible;
|
||||
// local->colision = remote->colision;
|
||||
//}
|
||||
|
||||
void Engine::ResponseToServerAndRefresh(std::shared_ptr<Network::Socket> sock) {
|
||||
if (sock->sock == 0) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user