Post Lists

2018년 10월 21일 일요일

Part 4 Collision Detection

Part 4 Collision Detection
Chapter 12 Collision Detection + (RTCD Book, other posts)

이 부분은 Broad Phase에 관한 것인데, Bounding Volume을 써서 Bounding Volume Hierarchy를 만들어서 하는 것을 설명하는데, 내가 확인해본 바로는 이 책 데모에서 이 Broad Phase를 쓴 것이 없다. 그래서 일단은 이 부분은 넘어간다.

하지만, 확실히 이것은 공부해서 적용해야할 것이긴 하다.

RTCD 책 기준으로 Chapter 4로 Bounding Volume에 대해 공부하고, Chapter 6 ~8로 그것을 Broad Phase를 구현하는 것에 대해 공부해야 한다.

Chpater 4 Bounding Volumes
Chapter 6 Bounding Volume Hierarchies
Chapter 7 Spatial Partitioning
Chapter 8 BSP Tree Hierarchies

여튼 이 책은 저 위의 챕터들을 아주 간략하게 정의했고, 챕터 4에서의 Bounding Volue의 구조를 이용하여, Chapter 6를 통해 그 구조를 만들어서 간단하게 Broad Phase를 구현했다.

내 생각엔 저걸 다하면 시간이 부족할 거 같으니 이 부분은 뛰어넘고, 다중에 다시 저기를 다시 공부하여 구현하도록 해야겠다.

Chapter 13 Generating Contacts
- Contact Generation
1 Fine collision detection step
2 Contact generation step

- Contact Patch -> A set of Point Contacts

  • Point-Face
  • Edge-Edge
  • Face-Face
  • Edge-Face
  • Point-Edge (ignored)
  • Point-Point (ignored)

- Contact Data
  • Collision(Contact) Point
  • Collision(Contact) Normal : 떨어지는 방향, 전통적으로 첫 번째 오브젝트가 있는 방향으로 
  • Penetration Depth

- Point - Face Contacts
Contact Normal : Face Normal
Contact Point : Object Point (뚫고 들어간점)
Penetration Depth : Object point와 표면에 사영된 점의 사이의 거리

- Edge - Edge Contacts

Contact Normal : CrossProduct(Edge, Edge)
Contact Point : 한 edge에서 다른 edge에 가장 가까운 점
Penetration Depth : 두 edge 사이의 거리

- Edge - Face Contacts : curved surface와 쓰인다 (capsule edge, sphere surface)
Contact Normal : Face Normal
Contact Point : 가장 깊은 관통점
Penetration Depth : 위의 점으로부터 계산 됌

- Face - Face Contacts : Curved Surface with another face
Contact Normal : Normal of the first object face
Contact Point : 가장 깊은 괕오점
Penetration Depth : 위의 점으로부터 계산

- 구현된 primitive tests : GPED 코드 및 RTCD 참조!!
* Sphere - Sphere
* Box - Plane : Early-out -> RTCD TestOBBPlane
                    Point-Face contacts : 각 모서리 4개의 contacts
                    Edge-Plane - > two point-face contacts
* Box - Sphere : Sphere center를 Box local space로 변환
                      SAT Test
                      box local space에서 그 변환된 center로 box에 가장 가까운 점을 찾기
* Box - Box 
face-face -> four point - face contacts or four edge-edge contacts
face-edge -> two point-face contacts or two edge-edge contacts
point-point, point-edge : 거의 발생 할 일이 없어서 생략, 모서리로 box 균형 맞추거나 모서리와 edge로 균형 맞추는 시뮬레이션은 구현 못함. 그러나 이런 것들은 거의 안쓰임.

Algorithm : SAT Test -> Full Collision Detection

Point-Face - 주된 축에 사영, vertex가 box안에 있다 -> Point-face case
                 vertex가 box안에 있다 -> point-face case
                 정점이 한 개 이상 축에 박스 안이라면, 가장 얕은 penetration 사용

Point-face 시 Point를 box local space로 바꾸고, 각 축에 penetration test하고, normal 계산한다. 내 생각엔 boxAndPoint가 코드에서 안 쓰이는데, 어쨋든 거기에서 normal을 -1 곱해서 반대로 해야 되지 않나 생각이 듬.

현재 코드에서 쓰이는 boxAndBox 코드는
15개의 축에 대해 SAT 테스트를 하고, 거기에서 가장 작은 penetration을 가진 것에 대해서만 처리하여 한 개의 contacts를 반환함.
이 때 앞의 6개의 축은 각 box의 axis에 대한 것인데, 그 때는 PointFace 로 처리함.
뒤의 나머지 9개의 축은 edge-edge contact로서, 그 normal이 되는 axis를 찾고, 각 box의 edge를 찾음. 각 edge를 찾아서, world space로 변경한 후에, 두 edge 사이의 가장 가까운 점을 찾아서 contact generation을 한다. 두 edge 사이의 가장 가까운 점을 찾는 코드는 RTCD책의 ClosestPtSegmentSegment 을 참조.

댓글 없음:

댓글 쓰기