일단 충돌 구현...?

This commit is contained in:
2025-06-19 17:34:34 +09:00
parent dc2c106bad
commit 3e3769f912
8 changed files with 81 additions and 73 deletions

View File

@@ -14,7 +14,8 @@ void BeginPlay(veng::Engine& engine) {
player->position = glm::vec3(jitterDist(gen), jitterDist(gen), 0.f);
player->scale = glm::vec3(.02f);
player->colision = true;
player->OnColision = [](std::shared_ptr<veng::Model> self,
player->OnColision = [](utils::ThreadPool* thread_pool,
std::shared_ptr<veng::Model> self,
std::shared_ptr<veng::Model> other) {
auto self_owner = self->owner.lock();
auto other_owner = other->owner.lock();
@@ -51,6 +52,27 @@ void BeginPlay(veng::Engine& engine) {
std::lock_guard lock(other_player->modding);
other_player->position = glm::vec3(1.f, 0.f, 0.f);
other_player->scale = glm::vec3(.02f);
player->colision = true;
player->OnColision = [](utils::ThreadPool* thread_pool,
std::shared_ptr<veng::Model> self,
std::shared_ptr<veng::Model> other) {
auto self_owner = self->owner.lock();
auto other_owner = other->owner.lock();
if (other_owner == nullptr || self_owner == nullptr) return;
if (other_owner->ID == self->ID) return;
spdlog::info("[{}:{}] and [{}:{}] is nearby.", self->name,
self->ID.snowflake, other->name, other->ID.snowflake);
spdlog::info("[{}:{}] 's owner: [{}:{}]", self->name, self->ID.snowflake,
self_owner->name, self_owner->ID.snowflake);
spdlog::info("[{}:{}] 's owner: [{}:{}]", other->name,
other->ID.snowflake, other_owner->name,
other_owner->ID.snowflake);
other->colision = false;
other->visible = false;
other->shouldBeDestroyed = true;
};
other_player->colision = true;
}

View File

@@ -86,8 +86,9 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
bullet->owner = player;
bullet->scale = player->scale;
bullet->colision = true;
bullet->OnColision = [](std::shared_ptr<veng::Model> self,
std::shared_ptr<veng::Model> other) {
bullet->OnColision = [](utils::ThreadPool* thread_pool,
std::shared_ptr<veng::Model> self,
std::shared_ptr<veng::Model> other) {
auto self_owner = self->owner.lock();
auto other_owner = other->owner.lock();
if (other_owner == nullptr || self_owner == nullptr) return;
@@ -112,30 +113,35 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
}
static bool ad_laststate = false;
right = player->rotation * glm::vec3(0, 0, 1);
if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(), GLFW_KEY_A) ==
GLFW_PRESS) {
right = player->rotation * glm::vec3(0, 0, 1);
player->angular_velocity = right * 6.f;
if (!ad_laststate) {
player->needsUpdate = true;
player->updateRedundantCount = 0;
player->updateRedundantCount = 1;
ad_laststate = true;
}
} else if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(),
}
if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(),
GLFW_KEY_D) == GLFW_PRESS) {
right = player->rotation * glm::vec3(0, 0, 1);
player->angular_velocity = right * -6.f;
if (!ad_laststate) {
player->needsUpdate = true;
player->updateRedundantCount = 0;
player->updateRedundantCount = 1;
ad_laststate = true;
}
} else {
right = player->rotation * glm::vec3(0, 0, 1);
}
if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(), GLFW_KEY_A) ==
GLFW_RELEASE &&
glfwGetKey(engine.vulkan_graphics->window->GetHandle(), GLFW_KEY_D) ==
GLFW_RELEASE) {
player->angular_velocity = right * 0.f;
if (ad_laststate) {
player->needsUpdate = true;
player->updateRedundantCount = 0;
player->updateRedundantCount = 2;
ad_laststate = false;
}
}