Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Optimize Collision Detection with Octree

3c557c6103a4addc52f7b76ffd0a0f27?s=47 yomotsu
October 08, 2014

Optimize Collision Detection with Octree

3c557c6103a4addc52f7b76ffd0a0f27?s=128

yomotsu

October 08, 2014
Tweet

Transcript

  1. 1 Optimize Collision Detection with Octree Presented by Akihiro Oyamada

    (@yomotsu) Frontend Engineer at PixelGrid, Inc. Oct 7, 2014
  2. 2

  3. 3

  4. 4

  5. 5

  6. 6

  7. 7 Collision Detection vs 524 Tris

  8. 8 vs only about 30 Tris
 by partitioning

  9. ෼ׂۭͨؒ͠͸ .PSUPOPSEFSʹैͬͯฒ΂Δ 9

  10. 10

  11. 11

  12. 12

  13. 13

  14. 14

  15. 15 // maxDepth4のoctreeのツリー構成例 ! octree.nodes = [ [node], //level 1

    (node*1個) [node,node...] //level 2 (node*8個) [node,node...] //level 3 (node*64個) [node,node...] //level 4 (node*512個) ]
  16. 16 // node単体の構成例 ! OctreeNode = function ( params )

    { ! this.tree // <Octree> this.depth // <Number> this.mortonNumber // <Number> this.min // <THREE.Vector3> this.max // <THREE.Vector3> this.trianglePool // <Array> ! }
  17. 17 -FWFMͷͷࢠϊʔυΛٻΊΔʹ͸ʜ

  18. 18 var i; ! var parentMotonNum = 1; ! for

    ( i = 0; i < 8; i ++ ) { ! console.log( ( parentMotonNum << 3 ) + i ); ! } ! // 8, 9, 10, 11, 12, 14, 15
  19. 19 -FWFMͷͷ਌ϊʔυΛٻΊΔʹ͸ʜ

  20. 20 var childMotonNum = 10; console.log( childMotonNum >> 3 );

    ! // 1
  21. ϏοτγϑτͰ
 ٻΊΒΕΔ 21

  22. ϊʔυʹ஍ܗͷ
 τϥΠΞϯάϧΛొ࿥͢Δ 22

  23. ""##WT5SJBOHMF ϊʔυ͸""## 23

  24. 24

  25. 25

  26. NBY%FQUIΛʹͨ͠Β
 $ISPNF͕ࢭ·ͬͨ
 ? ? ? ʜ ? ݸͷϊʔυ͕Ͱ͖Δ 26

  27. ܁Γฦ͠ͷ਺ΛݮΒ͢͜ͱ͕Ͱ͖ ͨ 27

  28. %Ͱ͸͋Δ͚ΕͲɺ
 ஍ܗ͸ฏ໘ʹ͍ۙͷͰɺ
 2VBEUSFF % Ͱ΋͍͍͔΋ .PSUPO/VNͱϏοτγϑτ 28

  29. • THREE.RayΛ΍Ίͯɺಠࣗͷ
 Segment-Triangleަࠩςετʹஔ͖׵͑ • ίϝϯτΛେྔʹೖΕͨ(೔ຊޠ͚ͩͲ) 29 ଞʹ΍ͬͨ͜ͱ

  30. 30 gl.finish(); @yomotsu