1Optimize Collision Detectionwith OctreePresented by Akihiro Oyamada (@yomotsu)Frontend Engineer at PixelGrid, Inc.Oct 7, 2014
View Slide
2
3
4
5
6
7Collision Detectionvs 524 Tris
8vs only about 30 Tris by partitioning
ׂۭͨؒ͠.PSUPOPSEFSʹैͬͯฒΔ9
10
11
12
13
14
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// node単体の構成例!OctreeNode = function ( params ) {!this.tree // this.depth // this.mortonNumber // this.min // this.max // this.trianglePool // !}
17-FWFMͷͷࢠϊʔυΛٻΊΔʹʜ
18var i;!var parentMotonNum = 1;!for ( i = 0; i < 8; i ++ ) {!console.log( ( parentMotonNum << 3 ) + i );!}!// 8, 9, 10, 11, 12, 14, 15
19-FWFMͷͷϊʔυΛٻΊΔʹʜ
20var childMotonNum = 10;console.log( childMotonNum >> 3 );!// 1
ϏοτγϑτͰ ٻΊΒΕΔ21
ϊʔυʹܗͷ τϥΠΞϯάϧΛొ͢Δ22
""##WT5SJBOHMFϊʔυ""##23
24
25
NBY%FQUIΛʹͨ͠Β $ISPNF͕ࢭ·ͬͨ ? ? ?ʜ ?ݸͷϊʔυ͕Ͱ͖Δ26
܁Γฦ͠ͷΛݮΒ͢͜ͱ͕Ͱ͖ͨ27
%Ͱ͋Δ͚ΕͲɺ ܗฏ໘ʹ͍ۙͷͰɺ 2VBEUSFF %Ͱ͍͍͔.PSUPO/VNͱϏοτγϑτ28
• THREE.RayΛΊͯɺಠࣗͷ Segment-Triangleަࠩςετʹஔ͖͑• ίϝϯτΛେྔʹೖΕͨ(ຊޠ͚ͩͲ)29ଞʹͬͨ͜ͱ
30gl.finish();@yomotsu