-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollision_handler.cpp
More file actions
24 lines (20 loc) · 1.06 KB
/
collision_handler.cpp
File metadata and controls
24 lines (20 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "collision_handler.h"
#include "cloth_handler.h"
// CollisionHandler::CollisionHandler(){
//
// }
void CollisionHandler::HandleCollision(ClothHandler& cloth, std::vector<Sphere*> spheres, float delta_t){
for(Sphere* sphere : spheres){
for(int i = 0; i < Global::cloth_rows; i++){
for(int j = 0; j < Global::cloth_cols; j++){
float dis_to_sphere = glm::length(cloth.cloth_position + cloth.cloth_vertices[i][j].next_position - sphere->position);
if(dis_to_sphere < sphere->radius+0.03){
// cloth.cloth_vertices[i][j].AddForce(glm::normalize(cloth.cloth_position + cloth.cloth_vertices[i][j].next_position - sphere->position)*30.0f);
// cloth.cloth_vertices[i][j].CalculateNextPos(delta_t);
// following line is for infinite friction but I don't think it would work for moving objects
cloth.cloth_vertices[i][j].next_position = cloth.cloth_vertices[i][j].position;
}
}
}
}
}