일단은 멀티로 접속이 됨..

This commit is contained in:
2025-06-19 02:42:49 +09:00
parent 1b79d946c3
commit fc8217a608
25 changed files with 584 additions and 574 deletions

View File

@@ -5,34 +5,36 @@
namespace veng {
void Physics::invokeOnColisionEvent(
gsl::not_null<utils::ThreadPool*> thread_pool, gsl::span<Model*> models) {
gsl::not_null<utils::ThreadPool*> thread_pool, std::vector<std::shared_ptr<Model>> models) {
constexpr std::float_t EPSILON = std::numeric_limits<std::float_t>::epsilon();
for (int first = 0; first < models.size(); first++) {
if (!models[first]->colision) continue;
auto first_model = models[first];
if (first_model != nullptr || !first_model->colision) continue;
for (int second = first + 1; second < models.size(); second++) {
if (!models[second]->colision) continue;
auto second_model = models[second];
if (second_model != nullptr || !second_model->colision) continue;
std::float_t distance =
glm::distance(models[first]->position, models[second]->position);
std::float_t model1_radius =
models[first]->radius * models[first]->scale.x;
std::float_t model2_radius =
models[second]->radius * models[second]->scale.x;
glm::distance(first_model->position, second_model->position);
std::float_t model1_radius = first_model->radius * first_model->scale.x;
std::float_t model2_radius = second_model->radius * second_model->scale.x;
if (distance <= model1_radius + model2_radius) {
if (models[first]->OnColision != nullptr)
if (first_model->OnColision != nullptr)
thread_pool->enqueueJob(
[OnColision = models[first]->OnColision](
utils::ThreadPool* thread_pool, Model* self, Model* other) {
[OnColision = first_model->OnColision](
utils::ThreadPool* thread_pool, std::shared_ptr<Model> self,
std::shared_ptr<Model> other) {
OnColision(self, other);
},
models[first], models[second]);
if (models[second]->OnColision != nullptr)
first_model, second_model);
if (second_model->OnColision != nullptr)
thread_pool->enqueueJob(
[OnColision = models[second]->OnColision](
utils::ThreadPool* thread_pool, Model* self, Model* other) {
[OnColision = second_model->OnColision](
utils::ThreadPool* thread_pool, std::shared_ptr<Model> self,
std::shared_ptr<Model> other) {
OnColision(self, other);
},
models[second], models[first]);
first_model, second_model);
break;
}
}