├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── LatexNotes.md ├── Notes.md ├── README.md ├── data ├── PyramidBase.txt ├── PyramidRotate.txt ├── bullet_tiles.txt ├── tiles2_bb_nr.txt ├── tiles2_bb_rot.txt ├── tiles2_grd_nr.txt ├── tiles2_grd_rot.txt └── tiles2_svg.sh ├── docs ├── DynamicTree.bib ├── DynamicTree.tex ├── Erin Catto - Dynamic BVH GDC.pptx ├── Erin Catto - Dynamic BVH.pptx ├── images │ ├── AreaCompare.svg │ ├── Balanced.svg │ ├── Balanced_back.svg │ ├── BlizzardLand1000_BottomUp.png │ ├── BlizzardWorld.png │ ├── BlizzardWorldBalloons.png │ ├── BlizzardWorldBoxes.png │ ├── BlizzardWorldOverlayBoxes.png │ ├── BlizzardWorldZoomed.png │ ├── BulletTiles.png │ ├── Child1Internal.svg │ ├── Child1Leaf.svg │ ├── EquivalentTrees.svg │ ├── ExampleBinaryTree.svg │ ├── InflatedAABBs.svg │ ├── LinkedList.svg │ ├── LooseObjects.svg │ ├── LooseOverlap.svg │ ├── LooseRayCast.svg │ ├── NewGrandParent.svg │ ├── NewLeaf.svg │ ├── Pyramid.png │ ├── PyramidBase.svg │ ├── PyramidRotate.svg │ ├── Rotate.svg │ ├── RotateDiff.svg │ ├── RotateDiffContrib.svg │ ├── RotatePossible.svg │ ├── SingleLeaf.svg │ ├── TileBased.svg │ ├── TiledBottomUp.png │ ├── Tiles.png │ ├── TreeInsert1.svg │ ├── TreeInsert2.svg │ ├── TreeInsert3.svg │ ├── TreeInsertBase.svg │ ├── TreeInsertCost.svg │ ├── TreeInsertHighlight7.svg │ ├── TreeInsertHighlight89.svg │ ├── TreeOverlay.svg │ ├── minecraft.png │ ├── sort_balanced.svg │ ├── sort_linked.svg │ ├── terraria.png │ ├── tiles2_bb_nr.svg │ ├── tiles2_bb_rot.svg │ ├── tiles2_grd_nr.svg │ └── tiles2_grd_rot.svg └── refs │ ├── A. Kensler - Tree Rotations for Improving Bounding Volume Hierarchies.pdf │ ├── D. Kopta - Fast, Effective BVH Updates for Animated Scenes.pdf │ ├── G. van den Bergen - Efficient Collision Detection of Complex Deformable Models.pdf │ ├── I. Wald - Ray Tracing Deformable Scenes.pdf │ ├── J. Bittner - Fast Insertion-Based Optimization.pdf │ ├── J. Bittner - Incremental BVH Construction for Ray Tracing.pdf │ ├── J. Goldsmith - Automatic Creation of Object Hierarchies.pdf │ ├── M. Otaguy - Balanced Hierarchies for Collision Detection.pdf │ ├── Notes.md │ ├── S. Omohundro - Five Balltree Construction Algorithms.pdf │ └── T. Larsson - A Dynamic Bounding Volume Hierarchy.pdf ├── extern ├── dbvt │ ├── btDbvt_orig.cpp │ └── btDbvt_orig.h ├── glfw │ ├── CMakeLists.txt │ ├── include │ │ └── GLFW │ │ │ ├── glfw3.h │ │ │ └── glfw3native.h │ └── src │ │ ├── cocoa_init.m │ │ ├── cocoa_joystick.h │ │ ├── cocoa_joystick.m │ │ ├── cocoa_monitor.m │ │ ├── cocoa_platform.h │ │ ├── cocoa_time.c │ │ ├── cocoa_window.m │ │ ├── context.c │ │ ├── egl_context.c │ │ ├── egl_context.h │ │ ├── glfw_config.h │ │ ├── glx_context.c │ │ ├── glx_context.h │ │ ├── init.c │ │ ├── input.c │ │ ├── internal.h │ │ ├── linux_joystick.c │ │ ├── linux_joystick.h │ │ ├── mappings.h │ │ ├── mappings.h.in │ │ ├── monitor.c │ │ ├── nsgl_context.h │ │ ├── nsgl_context.m │ │ ├── null_init.c │ │ ├── null_joystick.c │ │ ├── null_joystick.h │ │ ├── null_monitor.c │ │ ├── null_platform.h │ │ ├── null_window.c │ │ ├── osmesa_context.c │ │ ├── osmesa_context.h │ │ ├── posix_thread.c │ │ ├── posix_thread.h │ │ ├── posix_time.c │ │ ├── posix_time.h │ │ ├── vulkan.c │ │ ├── wgl_context.c │ │ ├── wgl_context.h │ │ ├── win32_init.c │ │ ├── win32_joystick.c │ │ ├── win32_joystick.h │ │ ├── win32_monitor.c │ │ ├── win32_platform.h │ │ ├── win32_thread.c │ │ ├── win32_time.c │ │ ├── win32_window.c │ │ ├── window.c │ │ ├── wl_init.c │ │ ├── wl_monitor.c │ │ ├── wl_platform.h │ │ ├── wl_window.c │ │ ├── x11_init.c │ │ ├── x11_monitor.c │ │ ├── x11_platform.h │ │ ├── x11_window.c │ │ ├── xkb_unicode.c │ │ └── xkb_unicode.h ├── imgui │ ├── CMakeLists.txt │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_internal.h │ ├── imgui_widgets.cpp │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h └── sajson │ ├── CMakeLists.txt │ └── sajson.h ├── include └── dynamic-tree │ ├── tree.h │ └── utils.h ├── launch.sh ├── math.natvis ├── samples ├── CMakeLists.txt ├── data │ ├── BlizzardLand.txt │ ├── BlizzardLandDynamic.txt │ ├── BlizzardLandEditor.txt │ ├── BlizzardLandKinematic.txt │ ├── BlizzardLandStatic.txt │ ├── DroidSans.ttf │ ├── Gibraltar.txt │ ├── Himalayas.txt │ └── Mexico.txt ├── dot.sh ├── dot.svg ├── dot.txt ├── draw.cpp ├── draw.h ├── glad.c ├── glad.h ├── imgui_impl_glfw.cpp ├── imgui_impl_glfw.h ├── imgui_impl_opengl3.cpp ├── imgui_impl_opengl3.h ├── khrplatform.h ├── main.cpp ├── settings.cpp ├── settings.h ├── sort_balanced.svg ├── sort_linked.svg ├── test.cpp ├── test.h ├── test1.cpp ├── test2.cpp ├── test3.cpp └── test4.cpp └── src ├── CMakeLists.txt ├── tree.cpp └── utils.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pdf filter=lfs diff=lfs merge=lfs -text 2 | *.pptx filter=lfs diff=lfs merge=lfs -text 3 | *.png filter=lfs diff=lfs merge=lfs -text 4 | *.jpg filter=lfs diff=lfs merge=lfs -text 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | svg-inkscape/ 2 | *.aux 3 | *.bbl 4 | *.gz 5 | *.log 6 | *.blg 7 | *.ini 8 | *.pdf 9 | *.out 10 | build/ 11 | .vscode/ 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | project(dynamic-tree LANGUAGES CXX) 4 | 5 | set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE) 6 | 7 | add_subdirectory(src) 8 | 9 | option(BUILD_SAMPLES "Build the dynamic-tree sample program" ON) 10 | 11 | if (BUILD_SAMPLES) 12 | 13 | find_package(OpenGL REQUIRED) 14 | 15 | add_subdirectory(extern/glfw) 16 | add_subdirectory(extern/imgui) 17 | add_subdirectory(extern/sajson) 18 | add_subdirectory(samples) 19 | 20 | # default startup project for Visual Studio 21 | if (MSVC) 22 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT samples) 23 | set_property(TARGET samples PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/samples") 24 | endif() 25 | 26 | endif() 27 | -------------------------------------------------------------------------------- /LatexNotes.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | * Miktex for windows 3 | * git bash 4 | * Inkscape 5 | * Sublimetext3 with LatexTools 6 | * SumatraPDF 7 | * graphviz 8 | 9 | It is possible to have LatexTools build with Ctrl-B and synchronize the pdf in SumatraPDF. It requires a small amount of configuration. -------------------------------------------------------------------------------- /Notes.md: -------------------------------------------------------------------------------- 1 | I’m planning to give a talk on Dynamic AABB trees. I can do this in 25 minutes and I think it can be mostly visual. Key concepts: 2 | 3 | 4 | - Build tree of AABB to speed up ray casts and overlap tests for large worlds 5 | - Build the tree incrementally to handle dynamic worlds and streaming 6 | - Use enlarged AABBs so that objects have wiggle room before needing to update the tree 7 | - Introduce the Surface Area Heuristic as an optimization strategy to make ray casts faster 8 | - Show why SAH is better than a balanced tree or median split 9 | - Discuss using the SAH in a greedy fashion when inserting new nodes 10 | - Discuss using tree rotations to improve the SAH metric 11 | - Discuss incremental optimization of the tree 12 | - Discuss ray-cast/overlap test 13 | 14 | 15 | Title: 16 | Dynamic Bounding Volume Hierarchies 17 | 18 | Session Summary: 19 | Bounding volume hierarchies are used to accelerate ray casts, overlap queries, and closest point queries for large game worlds. Dynamic hierarchies allow objects to be created, destroyed, and moved while maintaining fast queries. Careful construction techniques can be used to avoid performance pitfalls that are common in procedurally generated game worlds. 20 | 21 | Takeaway: 22 | This session demonstrates how to build a dynamic bounding volume hierarchy while optimizing for query speed. 23 | 24 | Intended Audience: 25 | Anyone interested in ray casting and large game worlds. Knowledge of basic data structures such as binary trees is assumed. 26 | 27 | Speaker Bio: 28 | Erin Catto is a physics and animation lead at Blizzard Entertainment working on the shared game engine project. Erin got his start in the game industry at Crystal Dynamics where he wrote the physics engine for Tomb Raider: Legend. He is currently working on the Domino physics engine used by Diablo 3, StarCraft, Overwatch, World of WarCraft, Heroes of the Storm, and Call of Duty. He is the author of the Box2D open source physics engine, used to create Crayon Physics, Limbo, and Angry Birds. 29 | 30 | 31 | /d/graphvis-2.38/bin/dot -Tsvg input.txt > output.svg 32 | 33 | TODO 34 | - height control example 35 | - more 36 | 37 | Tiles 2: 12x2, pyramid 8 38 | No Rotations 39 | Greedy: area = 136 40 | Branch and Bound: area = 134 41 | 42 | With Rotations 43 | Greedy: area = 113 44 | Branch and Bound: area = 112 45 | 46 | Tiles 3: 200x10, pyramid 20 47 | 48 | No Rotations 49 | Greedy: area = 12854, build time = 3.2ms 50 | Branch and Bound: area = 23032, build time = 23.2ms 51 | 52 | With Rotations 53 | Greedy: area = 5259, build time = 1.4ms 54 | Branch and Bound: area = 4960, build time = 4.4ms 55 | 56 | Links: 57 | https://jacco.ompf2.com/ 58 | https://meistdan.github.io/publications/bvh_star/paper.pdf 59 | 60 | 61 | SAH1 30.33 (35) 3.82 (26) 62 | SAH2 30.98 (45) 3.80 (30) 63 | 64 | tol = 0 65 | 31.07 (35), 3.82 (26), 2.27 (27), 1.26 (23), 0.93 (26) 66 | 67 | tol = 1e-75 * baseArea 68 | 31.06 (36), 3.82 (28), 2.27 (28), 1.26 (29), 0.93 (26) 69 | 70 | 71 | 38.17 (35) 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DynamicTree 2 | Dynamic tree paper and resources 3 | -------------------------------------------------------------------------------- /data/PyramidBase.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | 2 -- 0 4 | 2 -- 1 5 | 4 -- 2 6 | 4 -- 8 7 | 6 -- 3 8 | 6 -- 5 9 | 8 -- 24 10 | 8 -- 12 11 | 10 -- 7 12 | 10 -- 9 13 | 12 -- 10 14 | 12 -- 16 15 | 14 -- 11 16 | 14 -- 13 17 | 16 -- 14 18 | 16 -- 20 19 | 18 -- 15 20 | 18 -- 17 21 | 20 -- 18 22 | 20 -- 22 23 | 22 -- 19 24 | 22 -- 21 25 | 24 -- 6 26 | 24 -- 28 27 | 26 -- 23 28 | 26 -- 25 29 | 28 -- 36 30 | 28 -- 32 31 | 30 -- 27 32 | 30 -- 29 33 | 32 -- 30 34 | 32 -- 34 35 | 34 -- 31 36 | 34 -- 33 37 | 36 -- 26 38 | 36 -- 40 39 | 38 -- 35 40 | 38 -- 37 41 | 40 -- 46 42 | 40 -- 44 43 | 42 -- 39 44 | 42 -- 41 45 | 44 -- 42 46 | 44 -- 43 47 | 46 -- 38 48 | 46 -- 50 49 | 48 -- 45 50 | 48 -- 47 51 | 50 -- 54 52 | 50 -- 52 53 | 52 -- 49 54 | 52 -- 51 55 | 54 -- 48 56 | 54 -- 58 57 | 56 -- 53 58 | 56 -- 55 59 | 58 -- 60 60 | 58 -- 57 61 | 60 -- 56 62 | 60 -- 64 63 | 62 -- 59 64 | 62 -- 61 65 | 64 -- 62 66 | 64 -- 63 67 | 0 [shape=point, label=""] 68 | 1 [shape=point, label=""] 69 | 2 [shape=circle, label="6"] 70 | 3 [shape=point, label=""] 71 | 4 [shape=circle, label="41"] 72 | 5 [shape=point, label=""] 73 | 6 [shape=circle, label="6"] 74 | 7 [shape=point, label=""] 75 | 8 [shape=circle, label="37"] 76 | 9 [shape=point, label=""] 77 | 10 [shape=circle, label="6"] 78 | 11 [shape=point, label=""] 79 | 12 [shape=circle, label="18"] 80 | 13 [shape=point, label=""] 81 | 14 [shape=circle, label="6"] 82 | 15 [shape=point, label=""] 83 | 16 [shape=circle, label="14"] 84 | 17 [shape=point, label=""] 85 | 18 [shape=circle, label="6"] 86 | 19 [shape=point, label=""] 87 | 20 [shape=circle, label="10"] 88 | 21 [shape=point, label=""] 89 | 22 [shape=circle, label="6"] 90 | 23 [shape=point, label=""] 91 | 24 [shape=circle, label="32"] 92 | 25 [shape=point, label=""] 93 | 26 [shape=circle, label="6"] 94 | 27 [shape=point, label=""] 95 | 28 [shape=circle, label="28"] 96 | 29 [shape=point, label=""] 97 | 30 [shape=circle, label="6"] 98 | 31 [shape=point, label=""] 99 | 32 [shape=circle, label="11"] 100 | 33 [shape=point, label=""] 101 | 34 [shape=circle, label="6"] 102 | 35 [shape=point, label=""] 103 | 36 [shape=circle, label="27"] 104 | 37 [shape=point, label=""] 105 | 38 [shape=circle, label="6"] 106 | 39 [shape=point, label=""] 107 | 40 [shape=circle, label="23"] 108 | 41 [shape=point, label=""] 109 | 42 [shape=circle, label="6"] 110 | 43 [shape=point, label=""] 111 | 44 [shape=circle, label="9"] 112 | 45 [shape=point, label=""] 113 | 46 [shape=circle, label="22"] 114 | 47 [shape=point, label=""] 115 | 48 [shape=circle, label="6"] 116 | 49 [shape=point, label=""] 117 | 50 [shape=circle, label="18"] 118 | 51 [shape=point, label=""] 119 | 52 [shape=circle, label="6"] 120 | 53 [shape=point, label=""] 121 | 54 [shape=circle, label="17"] 122 | 55 [shape=point, label=""] 123 | 56 [shape=circle, label="6"] 124 | 57 [shape=point, label=""] 125 | 58 [shape=circle, label="14"] 126 | 59 [shape=point, label=""] 127 | 60 [shape=circle, label="12"] 128 | 61 [shape=point, label=""] 129 | 62 [shape=circle, label="6"] 130 | 63 [shape=point, label=""] 131 | 64 [shape=circle, label="9"] 132 | } 133 | -------------------------------------------------------------------------------- /data/PyramidRotate.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | 2 -- 19 4 | 2 -- 21 5 | 4 -- 28 6 | 4 -- 8 7 | 6 -- 0 8 | 6 -- 1 9 | 8 -- 54 10 | 8 -- 40 11 | 10 -- 3 12 | 10 -- 5 13 | 12 -- 20 14 | 12 -- 16 15 | 14 -- 7 16 | 14 -- 9 17 | 16 -- 18 18 | 16 -- 14 19 | 18 -- 11 20 | 18 -- 13 21 | 20 -- 22 22 | 20 -- 2 23 | 22 -- 15 24 | 22 -- 17 25 | 24 -- 10 26 | 24 -- 6 27 | 26 -- 31 28 | 26 -- 33 29 | 28 -- 36 30 | 28 -- 12 31 | 30 -- 23 32 | 30 -- 25 33 | 32 -- 34 34 | 32 -- 26 35 | 34 -- 27 36 | 34 -- 29 37 | 36 -- 46 38 | 36 -- 24 39 | 38 -- 43 40 | 38 -- 41 41 | 40 -- 32 42 | 40 -- 50 43 | 42 -- 35 44 | 42 -- 37 45 | 44 -- 38 46 | 44 -- 39 47 | 46 -- 42 48 | 46 -- 30 49 | 48 -- 49 50 | 48 -- 51 51 | 50 -- 44 52 | 50 -- 48 53 | 52 -- 45 54 | 52 -- 47 55 | 54 -- 64 56 | 54 -- 60 57 | 56 -- 57 58 | 56 -- 55 59 | 58 -- 56 60 | 58 -- 53 61 | 60 -- 58 62 | 60 -- 52 63 | 62 -- 59 64 | 62 -- 61 65 | 64 -- 62 66 | 64 -- 63 67 | 0 [shape=point] 68 | 1 [shape=point] 69 | 2 [shape=circle, label="6"] 70 | 3 [shape=point] 71 | 4 [shape=circle, label="41"] 72 | 5 [shape=point] 73 | 6 [shape=circle, label="6"] 74 | 7 [shape=point] 75 | 8 [shape=circle, label="26"] 76 | 9 [shape=point] 77 | 10 [shape=circle, label="6"] 78 | 11 [shape=point] 79 | 12 [shape=circle, label="18"] 80 | 13 [shape=point] 81 | 14 [shape=circle, label="6"] 82 | 15 [shape=point] 83 | 16 [shape=circle, label="10"] 84 | 17 [shape=point] 85 | 18 [shape=circle, label="6"] 86 | 19 [shape=point] 87 | 20 [shape=circle, label="10"] 88 | 21 [shape=point] 89 | 22 [shape=circle, label="6"] 90 | 23 [shape=point] 91 | 24 [shape=circle, label="10"] 92 | 25 [shape=point] 93 | 26 [shape=circle, label="6"] 94 | 27 [shape=point] 95 | 28 [shape=circle, label="31"] 96 | 29 [shape=point] 97 | 30 [shape=circle, label="6"] 98 | 31 [shape=point] 99 | 32 [shape=circle, label="11"] 100 | 33 [shape=point] 101 | 34 [shape=circle, label="6"] 102 | 35 [shape=point] 103 | 36 [shape=circle, label="18"] 104 | 37 [shape=point] 105 | 38 [shape=circle, label="6"] 106 | 39 [shape=point] 107 | 40 [shape=circle, label="16"] 108 | 41 [shape=point] 109 | 42 [shape=circle, label="6"] 110 | 43 [shape=point] 111 | 44 [shape=circle, label="9"] 112 | 45 [shape=point] 113 | 46 [shape=circle, label="10"] 114 | 47 [shape=point] 115 | 48 [shape=circle, label="6"] 116 | 49 [shape=point] 117 | 50 [shape=circle, label="11"] 118 | 51 [shape=point] 119 | 52 [shape=circle, label="6"] 120 | 53 [shape=point] 121 | 54 [shape=circle, label="17"] 122 | 55 [shape=point] 123 | 56 [shape=circle, label="6"] 124 | 57 [shape=point] 125 | 58 [shape=circle, label="9"] 126 | 59 [shape=point] 127 | 60 [shape=circle, label="12"] 128 | 61 [shape=point] 129 | 62 [shape=circle, label="6"] 130 | 63 [shape=point] 131 | 64 [shape=circle, label="9"] 132 | } 133 | -------------------------------------------------------------------------------- /data/tiles2_bb_nr.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | node[shape = point] 4 | 2 -- 26 5 | 2 -- 6 6 | 4 -- 1 7 | 4 -- 3 8 | 6 -- 48 9 | 6 -- 10 10 | 8 -- 5 11 | 8 -- 7 12 | 10 -- 78 13 | 10 -- 14 14 | 12 -- 9 15 | 12 -- 11 16 | 14 -- 12 17 | 14 -- 18 18 | 16 -- 13 19 | 16 -- 15 20 | 18 -- 60 21 | 18 -- 22 22 | 20 -- 17 23 | 20 -- 19 24 | 22 -- 20 25 | 22 -- 46 26 | 24 -- 0 27 | 24 -- 23 28 | 26 -- 24 29 | 26 -- 30 30 | 28 -- 25 31 | 28 -- 27 32 | 30 -- 28 33 | 30 -- 34 34 | 32 -- 29 35 | 32 -- 31 36 | 34 -- 32 37 | 34 -- 38 38 | 36 -- 33 39 | 36 -- 35 40 | 38 -- 36 41 | 38 -- 42 42 | 40 -- 37 43 | 40 -- 39 44 | 42 -- 40 45 | 42 -- 44 46 | 44 -- 41 47 | 44 -- 43 48 | 46 -- 21 49 | 46 -- 45 50 | 48 -- 4 51 | 48 -- 52 52 | 50 -- 47 53 | 50 -- 49 54 | 52 -- 64 55 | 52 -- 56 56 | 54 -- 51 57 | 54 -- 53 58 | 56 -- 54 59 | 56 -- 72 60 | 58 -- 55 61 | 58 -- 57 62 | 60 -- 16 63 | 60 -- 76 64 | 62 -- 59 65 | 62 -- 61 66 | 64 -- 50 67 | 64 -- 68 68 | 66 -- 63 69 | 66 -- 65 70 | 68 -- 66 71 | 68 -- 70 72 | 70 -- 67 73 | 70 -- 69 74 | 72 -- 58 75 | 72 -- 74 76 | 74 -- 71 77 | 74 -- 73 78 | 76 -- 62 79 | 76 -- 75 80 | 78 -- 8 81 | 78 -- 82 82 | 80 -- 77 83 | 80 -- 79 84 | 82 -- 90 85 | 82 -- 86 86 | 84 -- 81 87 | 84 -- 83 88 | 86 -- 94 89 | 86 -- 98 90 | 88 -- 85 91 | 88 -- 87 92 | 90 -- 80 93 | 90 -- 100 94 | 92 -- 89 95 | 92 -- 91 96 | 94 -- 84 97 | 94 -- 96 98 | 96 -- 93 99 | 96 -- 95 100 | 98 -- 88 101 | 98 -- 106 102 | 100 -- 92 103 | 100 -- 108 104 | 102 -- 99 105 | 102 -- 101 106 | 104 -- 102 107 | 104 -- 103 108 | 106 -- 97 109 | 106 -- 105 110 | 108 -- 104 111 | 108 -- 114 112 | 110 -- 107 113 | 110 -- 109 114 | 112 -- 110 115 | 112 -- 111 116 | 114 -- 112 117 | 114 -- 118 118 | 116 -- 113 119 | 116 -- 115 120 | 118 -- 116 121 | 118 -- 117 122 | 128 [shape=box, label="inner area = 134"] 123 | } 124 | graph 125 | { 126 | node[shape = point] 127 | 2 -- 26 128 | 2 -- 6 129 | 4 -- 1 130 | 4 -- 3 131 | 6 -- 48 132 | 6 -- 10 133 | 8 -- 5 134 | 8 -- 7 135 | 10 -- 78 136 | 10 -- 14 137 | 12 -- 9 138 | 12 -- 11 139 | 14 -- 12 140 | 14 -- 18 141 | 16 -- 13 142 | 16 -- 15 143 | 18 -- 60 144 | 18 -- 22 145 | 20 -- 17 146 | 20 -- 19 147 | 22 -- 20 148 | 22 -- 46 149 | 24 -- 0 150 | 24 -- 23 151 | 26 -- 24 152 | 26 -- 30 153 | 28 -- 25 154 | 28 -- 27 155 | 30 -- 28 156 | 30 -- 34 157 | 32 -- 29 158 | 32 -- 31 159 | 34 -- 32 160 | 34 -- 38 161 | 36 -- 33 162 | 36 -- 35 163 | 38 -- 36 164 | 38 -- 42 165 | 40 -- 37 166 | 40 -- 39 167 | 42 -- 40 168 | 42 -- 44 169 | 44 -- 41 170 | 44 -- 43 171 | 46 -- 21 172 | 46 -- 45 173 | 48 -- 4 174 | 48 -- 52 175 | 50 -- 47 176 | 50 -- 49 177 | 52 -- 64 178 | 52 -- 56 179 | 54 -- 51 180 | 54 -- 53 181 | 56 -- 54 182 | 56 -- 72 183 | 58 -- 55 184 | 58 -- 57 185 | 60 -- 16 186 | 60 -- 76 187 | 62 -- 59 188 | 62 -- 61 189 | 64 -- 50 190 | 64 -- 68 191 | 66 -- 63 192 | 66 -- 65 193 | 68 -- 66 194 | 68 -- 70 195 | 70 -- 67 196 | 70 -- 69 197 | 72 -- 58 198 | 72 -- 74 199 | 74 -- 71 200 | 74 -- 73 201 | 76 -- 62 202 | 76 -- 75 203 | 78 -- 8 204 | 78 -- 82 205 | 80 -- 77 206 | 80 -- 79 207 | 82 -- 90 208 | 82 -- 86 209 | 84 -- 81 210 | 84 -- 83 211 | 86 -- 94 212 | 86 -- 98 213 | 88 -- 85 214 | 88 -- 87 215 | 90 -- 80 216 | 90 -- 100 217 | 92 -- 89 218 | 92 -- 91 219 | 94 -- 84 220 | 94 -- 96 221 | 96 -- 93 222 | 96 -- 95 223 | 98 -- 88 224 | 98 -- 106 225 | 100 -- 92 226 | 100 -- 108 227 | 102 -- 99 228 | 102 -- 101 229 | 104 -- 102 230 | 104 -- 103 231 | 106 -- 97 232 | 106 -- 105 233 | 108 -- 104 234 | 108 -- 114 235 | 110 -- 107 236 | 110 -- 109 237 | 112 -- 110 238 | 112 -- 111 239 | 114 -- 112 240 | 114 -- 118 241 | 116 -- 113 242 | 116 -- 115 243 | 118 -- 116 244 | 118 -- 117 245 | 128 [shape=box, label="inner area = 134"] 246 | } 247 | graph 248 | { 249 | node[shape = point] 250 | 2 -- 26 251 | 2 -- 6 252 | 4 -- 1 253 | 4 -- 3 254 | 6 -- 48 255 | 6 -- 10 256 | 8 -- 5 257 | 8 -- 7 258 | 10 -- 78 259 | 10 -- 14 260 | 12 -- 9 261 | 12 -- 11 262 | 14 -- 12 263 | 14 -- 18 264 | 16 -- 13 265 | 16 -- 15 266 | 18 -- 60 267 | 18 -- 22 268 | 20 -- 17 269 | 20 -- 19 270 | 22 -- 20 271 | 22 -- 46 272 | 24 -- 0 273 | 24 -- 23 274 | 26 -- 24 275 | 26 -- 30 276 | 28 -- 25 277 | 28 -- 27 278 | 30 -- 28 279 | 30 -- 34 280 | 32 -- 29 281 | 32 -- 31 282 | 34 -- 32 283 | 34 -- 38 284 | 36 -- 33 285 | 36 -- 35 286 | 38 -- 36 287 | 38 -- 42 288 | 40 -- 37 289 | 40 -- 39 290 | 42 -- 40 291 | 42 -- 44 292 | 44 -- 41 293 | 44 -- 43 294 | 46 -- 21 295 | 46 -- 45 296 | 48 -- 4 297 | 48 -- 52 298 | 50 -- 47 299 | 50 -- 49 300 | 52 -- 64 301 | 52 -- 56 302 | 54 -- 51 303 | 54 -- 53 304 | 56 -- 54 305 | 56 -- 72 306 | 58 -- 55 307 | 58 -- 57 308 | 60 -- 16 309 | 60 -- 76 310 | 62 -- 59 311 | 62 -- 61 312 | 64 -- 50 313 | 64 -- 68 314 | 66 -- 63 315 | 66 -- 65 316 | 68 -- 66 317 | 68 -- 70 318 | 70 -- 67 319 | 70 -- 69 320 | 72 -- 58 321 | 72 -- 74 322 | 74 -- 71 323 | 74 -- 73 324 | 76 -- 62 325 | 76 -- 75 326 | 78 -- 8 327 | 78 -- 82 328 | 80 -- 77 329 | 80 -- 79 330 | 82 -- 90 331 | 82 -- 86 332 | 84 -- 81 333 | 84 -- 83 334 | 86 -- 94 335 | 86 -- 98 336 | 88 -- 85 337 | 88 -- 87 338 | 90 -- 80 339 | 90 -- 100 340 | 92 -- 89 341 | 92 -- 91 342 | 94 -- 84 343 | 94 -- 96 344 | 96 -- 93 345 | 96 -- 95 346 | 98 -- 88 347 | 98 -- 106 348 | 100 -- 92 349 | 100 -- 108 350 | 102 -- 99 351 | 102 -- 101 352 | 104 -- 102 353 | 104 -- 103 354 | 106 -- 97 355 | 106 -- 105 356 | 108 -- 104 357 | 108 -- 114 358 | 110 -- 107 359 | 110 -- 109 360 | 112 -- 110 361 | 112 -- 111 362 | 114 -- 112 363 | 114 -- 118 364 | 116 -- 113 365 | 116 -- 115 366 | 118 -- 116 367 | 118 -- 117 368 | 128 [shape=box, label="inner area = 134"] 369 | } 370 | graph 371 | { 372 | node[shape = point] 373 | 2 -- 26 374 | 2 -- 6 375 | 4 -- 1 376 | 4 -- 3 377 | 6 -- 48 378 | 6 -- 10 379 | 8 -- 5 380 | 8 -- 7 381 | 10 -- 78 382 | 10 -- 14 383 | 12 -- 9 384 | 12 -- 11 385 | 14 -- 12 386 | 14 -- 18 387 | 16 -- 13 388 | 16 -- 15 389 | 18 -- 60 390 | 18 -- 22 391 | 20 -- 17 392 | 20 -- 19 393 | 22 -- 20 394 | 22 -- 46 395 | 24 -- 0 396 | 24 -- 23 397 | 26 -- 24 398 | 26 -- 30 399 | 28 -- 25 400 | 28 -- 27 401 | 30 -- 28 402 | 30 -- 34 403 | 32 -- 29 404 | 32 -- 31 405 | 34 -- 32 406 | 34 -- 38 407 | 36 -- 33 408 | 36 -- 35 409 | 38 -- 36 410 | 38 -- 42 411 | 40 -- 37 412 | 40 -- 39 413 | 42 -- 40 414 | 42 -- 44 415 | 44 -- 41 416 | 44 -- 43 417 | 46 -- 21 418 | 46 -- 45 419 | 48 -- 4 420 | 48 -- 52 421 | 50 -- 47 422 | 50 -- 49 423 | 52 -- 64 424 | 52 -- 56 425 | 54 -- 51 426 | 54 -- 53 427 | 56 -- 54 428 | 56 -- 72 429 | 58 -- 55 430 | 58 -- 57 431 | 60 -- 16 432 | 60 -- 76 433 | 62 -- 59 434 | 62 -- 61 435 | 64 -- 50 436 | 64 -- 68 437 | 66 -- 63 438 | 66 -- 65 439 | 68 -- 66 440 | 68 -- 70 441 | 70 -- 67 442 | 70 -- 69 443 | 72 -- 58 444 | 72 -- 74 445 | 74 -- 71 446 | 74 -- 73 447 | 76 -- 62 448 | 76 -- 75 449 | 78 -- 8 450 | 78 -- 82 451 | 80 -- 77 452 | 80 -- 79 453 | 82 -- 90 454 | 82 -- 86 455 | 84 -- 81 456 | 84 -- 83 457 | 86 -- 94 458 | 86 -- 98 459 | 88 -- 85 460 | 88 -- 87 461 | 90 -- 80 462 | 90 -- 100 463 | 92 -- 89 464 | 92 -- 91 465 | 94 -- 84 466 | 94 -- 96 467 | 96 -- 93 468 | 96 -- 95 469 | 98 -- 88 470 | 98 -- 106 471 | 100 -- 92 472 | 100 -- 108 473 | 102 -- 99 474 | 102 -- 101 475 | 104 -- 102 476 | 104 -- 103 477 | 106 -- 97 478 | 106 -- 105 479 | 108 -- 104 480 | 108 -- 114 481 | 110 -- 107 482 | 110 -- 109 483 | 112 -- 110 484 | 112 -- 111 485 | 114 -- 112 486 | 114 -- 118 487 | 116 -- 113 488 | 116 -- 115 489 | 118 -- 116 490 | 118 -- 117 491 | 128 [shape=box, label="inner area = 134"] 492 | } 493 | -------------------------------------------------------------------------------- /data/tiles2_bb_rot.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | node[shape = point] 4 | 2 -- 12 5 | 2 -- 84 6 | 4 -- 1 7 | 4 -- 3 8 | 6 -- 26 9 | 6 -- 24 10 | 8 -- 31 11 | 8 -- 7 12 | 10 -- 54 13 | 10 -- 50 14 | 12 -- 64 15 | 12 -- 18 16 | 14 -- 37 17 | 14 -- 13 18 | 16 -- 22 19 | 16 -- 72 20 | 18 -- 16 21 | 18 -- 76 22 | 20 -- 43 23 | 20 -- 19 24 | 22 -- 44 25 | 22 -- 62 26 | 24 -- 0 27 | 24 -- 23 28 | 26 -- 4 29 | 26 -- 28 30 | 28 -- 25 31 | 28 -- 27 32 | 30 -- 5 33 | 30 -- 29 34 | 32 -- 8 35 | 32 -- 34 36 | 34 -- 9 37 | 34 -- 33 38 | 36 -- 11 39 | 36 -- 55 40 | 38 -- 14 41 | 38 -- 40 42 | 40 -- 15 43 | 40 -- 39 44 | 42 -- 17 45 | 42 -- 41 46 | 44 -- 20 47 | 44 -- 46 48 | 46 -- 21 49 | 46 -- 45 50 | 48 -- 10 51 | 48 -- 6 52 | 50 -- 30 53 | 50 -- 32 54 | 52 -- 53 55 | 52 -- 51 56 | 54 -- 52 57 | 54 -- 49 58 | 56 -- 36 59 | 56 -- 35 60 | 58 -- 38 61 | 58 -- 60 62 | 60 -- 57 63 | 60 -- 59 64 | 62 -- 42 65 | 62 -- 61 66 | 64 -- 70 67 | 64 -- 48 68 | 66 -- 67 69 | 66 -- 69 70 | 68 -- 77 71 | 68 -- 63 72 | 70 -- 78 73 | 70 -- 80 74 | 72 -- 56 75 | 72 -- 58 76 | 74 -- 75 77 | 74 -- 73 78 | 76 -- 88 79 | 76 -- 86 80 | 78 -- 68 81 | 78 -- 47 82 | 80 -- 65 83 | 80 -- 66 84 | 82 -- 83 85 | 82 -- 81 86 | 84 -- 106 87 | 84 -- 100 88 | 86 -- 71 89 | 86 -- 85 90 | 88 -- 74 91 | 88 -- 98 92 | 90 -- 79 93 | 90 -- 92 94 | 92 -- 89 95 | 92 -- 91 96 | 94 -- 82 97 | 94 -- 96 98 | 96 -- 93 99 | 96 -- 95 100 | 98 -- 87 101 | 98 -- 97 102 | 100 -- 90 103 | 100 -- 94 104 | 102 -- 103 105 | 102 -- 101 106 | 104 -- 102 107 | 104 -- 112 108 | 106 -- 118 109 | 106 -- 108 110 | 108 -- 104 111 | 108 -- 114 112 | 110 -- 107 113 | 110 -- 109 114 | 112 -- 105 115 | 112 -- 111 116 | 114 -- 110 117 | 114 -- 99 118 | 116 -- 113 119 | 116 -- 115 120 | 118 -- 116 121 | 118 -- 117 122 | 128 [shape=box, label="inner area = 112"] 123 | } 124 | -------------------------------------------------------------------------------- /data/tiles2_grd_nr.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | node[shape = point] 4 | 2 -- 0 5 | 2 -- 1 6 | 4 -- 24 7 | 4 -- 8 8 | 6 -- 3 9 | 6 -- 5 10 | 8 -- 48 11 | 8 -- 12 12 | 10 -- 7 13 | 10 -- 9 14 | 12 -- 32 15 | 12 -- 16 16 | 14 -- 11 17 | 14 -- 13 18 | 16 -- 36 19 | 16 -- 20 20 | 18 -- 15 21 | 18 -- 17 22 | 20 -- 40 23 | 20 -- 22 24 | 22 -- 19 25 | 22 -- 21 26 | 24 -- 2 27 | 24 -- 28 28 | 26 -- 23 29 | 26 -- 25 30 | 28 -- 26 31 | 28 -- 30 32 | 30 -- 27 33 | 30 -- 29 34 | 32 -- 54 35 | 32 -- 34 36 | 34 -- 31 37 | 34 -- 33 38 | 36 -- 38 39 | 36 -- 35 40 | 38 -- 58 41 | 38 -- 37 42 | 40 -- 62 43 | 40 -- 44 44 | 42 -- 39 45 | 42 -- 41 46 | 44 -- 42 47 | 44 -- 46 48 | 46 -- 43 49 | 46 -- 45 50 | 48 -- 6 51 | 48 -- 52 52 | 50 -- 47 53 | 50 -- 49 54 | 52 -- 64 55 | 52 -- 51 56 | 54 -- 10 57 | 54 -- 56 58 | 56 -- 53 59 | 56 -- 55 60 | 58 -- 14 61 | 58 -- 72 62 | 60 -- 57 63 | 60 -- 59 64 | 62 -- 18 65 | 62 -- 61 66 | 64 -- 50 67 | 64 -- 68 68 | 66 -- 63 69 | 66 -- 65 70 | 68 -- 78 71 | 68 -- 82 72 | 70 -- 67 73 | 70 -- 69 74 | 72 -- 60 75 | 72 -- 76 76 | 74 -- 71 77 | 74 -- 73 78 | 76 -- 86 79 | 76 -- 75 80 | 78 -- 66 81 | 78 -- 90 82 | 80 -- 77 83 | 80 -- 79 84 | 82 -- 70 85 | 82 -- 94 86 | 84 -- 81 87 | 84 -- 83 88 | 86 -- 74 89 | 86 -- 88 90 | 88 -- 85 91 | 88 -- 87 92 | 90 -- 80 93 | 90 -- 100 94 | 92 -- 89 95 | 92 -- 91 96 | 94 -- 84 97 | 94 -- 98 98 | 96 -- 93 99 | 96 -- 95 100 | 98 -- 108 101 | 98 -- 97 102 | 100 -- 92 103 | 100 -- 102 104 | 102 -- 99 105 | 102 -- 101 106 | 104 -- 96 107 | 104 -- 106 108 | 106 -- 103 109 | 106 -- 105 110 | 108 -- 104 111 | 108 -- 112 112 | 110 -- 107 113 | 110 -- 109 114 | 112 -- 114 115 | 112 -- 111 116 | 114 -- 110 117 | 114 -- 118 118 | 116 -- 113 119 | 116 -- 115 120 | 118 -- 116 121 | 118 -- 117 122 | 128 [shape=box, label="inner area = 136"] 123 | } 124 | -------------------------------------------------------------------------------- /data/tiles2_grd_rot.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | node[shape = point] 4 | 2 -- 3 5 | 2 -- 1 6 | 4 -- 6 7 | 4 -- 56 8 | 6 -- 10 9 | 6 -- 52 10 | 8 -- 21 11 | 8 -- 19 12 | 10 -- 18 13 | 10 -- 60 14 | 12 -- 31 15 | 12 -- 33 16 | 14 -- 36 17 | 14 -- 32 18 | 16 -- 35 19 | 16 -- 11 20 | 18 -- 38 21 | 18 -- 22 22 | 20 -- 13 23 | 20 -- 37 24 | 22 -- 46 25 | 22 -- 44 26 | 24 -- 0 27 | 24 -- 23 28 | 26 -- 48 29 | 26 -- 24 30 | 28 -- 25 31 | 28 -- 27 32 | 30 -- 28 33 | 30 -- 29 34 | 32 -- 34 35 | 32 -- 12 36 | 34 -- 5 37 | 34 -- 7 38 | 36 -- 16 39 | 36 -- 9 40 | 38 -- 20 41 | 38 -- 40 42 | 40 -- 15 43 | 40 -- 39 44 | 42 -- 43 45 | 42 -- 45 46 | 44 -- 8 47 | 44 -- 42 48 | 46 -- 17 49 | 46 -- 41 50 | 48 -- 2 51 | 48 -- 30 52 | 50 -- 59 53 | 50 -- 61 54 | 52 -- 14 55 | 52 -- 26 56 | 54 -- 47 57 | 54 -- 49 58 | 56 -- 68 59 | 56 -- 82 60 | 58 -- 51 61 | 58 -- 53 62 | 60 -- 62 63 | 60 -- 76 64 | 62 -- 55 65 | 62 -- 57 66 | 64 -- 54 67 | 64 -- 58 68 | 66 -- 71 69 | 66 -- 73 70 | 68 -- 72 71 | 68 -- 78 72 | 70 -- 63 73 | 70 -- 65 74 | 72 -- 98 75 | 72 -- 86 76 | 74 -- 67 77 | 74 -- 69 78 | 76 -- 50 79 | 76 -- 75 80 | 78 -- 90 81 | 78 -- 64 82 | 80 -- 81 83 | 80 -- 83 84 | 82 -- 114 85 | 82 -- 100 86 | 84 -- 77 87 | 84 -- 79 88 | 86 -- 66 89 | 86 -- 74 90 | 88 -- 85 91 | 88 -- 87 92 | 90 -- 84 93 | 90 -- 70 94 | 92 -- 89 95 | 92 -- 91 96 | 94 -- 80 97 | 94 -- 96 98 | 96 -- 93 99 | 96 -- 95 100 | 98 -- 88 101 | 98 -- 97 102 | 100 -- 104 103 | 100 -- 94 104 | 102 -- 103 105 | 102 -- 105 106 | 104 -- 108 107 | 104 -- 110 108 | 106 -- 99 109 | 106 -- 101 110 | 108 -- 106 111 | 108 -- 92 112 | 110 -- 107 113 | 110 -- 109 114 | 112 -- 102 115 | 112 -- 111 116 | 114 -- 112 117 | 114 -- 118 118 | 116 -- 113 119 | 116 -- 115 120 | 118 -- 116 121 | 118 -- 117 122 | 128 [shape=box, label="inner area = 113"] 123 | } 124 | -------------------------------------------------------------------------------- /data/tiles2_svg.sh: -------------------------------------------------------------------------------- 1 | /d/graphviz-2.38/bin/dot -Tsvg tiles2_bb_nr.txt > tiles2_bb_nr.svg 2 | /d/graphviz-2.38/bin/dot -Tsvg tiles2_bb_rot.txt > tiles2_bb_rot.svg 3 | /d/graphviz-2.38/bin/dot -Tsvg tiles2_grd_nr.txt > tiles2_grd_nr.svg 4 | /d/graphviz-2.38/bin/dot -Tsvg tiles2_grd_rot.txt > tiles2_grd_rot.svg 5 | -------------------------------------------------------------------------------- /docs/DynamicTree.bib: -------------------------------------------------------------------------------- 1 | @article {Goldsmith1987, 2 | author = {Jeffrey Goldsmith and John Salmon}, 3 | title = {Automatic Creation of Object Hierarchies for Ray Tracing}, 4 | journal = {IEEE Computer Graphics and Applications}, 5 | year = {1987}, 6 | volume = {7}, 7 | number = {5}, 8 | pages = {14--20} 9 | } 10 | 11 | @techreport {Omohundrol1989, 12 | author = {Stephen M. Omohundrol and Stephen M. Omohundro}, 13 | title = {Five Balltree Construction Algorithms}, 14 | year = {1989} 15 | } 16 | 17 | @article {Bergen1998, 18 | author = {Gino van den Bergen}, 19 | title = {Efficient Collision Detection of Complex Deformable Models using AABB Trees}, 20 | journal = {J. Graphics Tools}, 21 | year = {1998}, 22 | volume = {2} 23 | } 24 | 25 | @book {Bergen2004, 26 | author = {Gino van den Bergen}, 27 | title = {Collision Detection in Interactive 3D Environments}, 28 | publisher = {Elsevier}, 29 | year = 2004 30 | } 31 | 32 | @article {Larsson2006, 33 | author = "Thomas Larsson and Tomas Akenine-Möller", 34 | title = "A dynamic bounding volume hierarchy for generalized collision detection", 35 | journal = "Computers \& Graphics", 36 | volume = "30", 37 | number = "3", 38 | pages = "450 - 459", 39 | year = "2006" 40 | } 41 | 42 | @inproceedings {Otaduy2007, 43 | author={Miguel A. Otaduy and Oliver Chassot and Denis Steinemann and Markus Gross}, 44 | booktitle={2007 IEEE Virtual Reality Conference}, 45 | title={Balanced Hierarchies for Collision Detection between Fracturing Objects}, 46 | year={2007}, 47 | pages={83-90} 48 | } 49 | 50 | @article {Kensler2008, 51 | title={Tree rotations for improving bounding volume hierarchies}, 52 | author={Andrew Kensler}, 53 | journal={2008 IEEE Symposium on Interactive Ray Tracing}, 54 | year={2008}, 55 | pages={73-76} 56 | } 57 | 58 | @inproceedings {Kopta2012, 59 | author = {Daniel Kopta and Thiago Ize and Josef Spjut and Erik Brunvand and Al Davis and Andrew Kensler}, 60 | title = {Fast, Effective BVH Updates for Animated Scenes}, 61 | booktitle = {Proceedings of the ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games}, 62 | series = {I3D '12}, 63 | year = {2012}, 64 | pages = {197--204}, 65 | numpages = {8}, 66 | } 67 | 68 | @article {Bittner2013, 69 | author = {Ji\v{r}\'{\i} Bittner and Michal Hapala and Vlastimil Havran}, 70 | title = {Fast Insertion-Based Optimization of Bounding Volume Hierarchies}, 71 | journal = {Computer Graphics Forum}, 72 | year = {2013}, 73 | volume = {32}, 74 | number = {1}, 75 | pages = {85--100} 76 | } 77 | 78 | @inproceedings {Vinkler2014, 79 | author = {Vinkler, Marek and Havran, Vlastimil and Bittner, Ji\v{r}\'{\i}}, 80 | title = {Bounding Volume Hierarchies Versus Kd-trees on Contemporary Many-core Architectures}, 81 | booktitle = {Proceedings of the 30th Spring Conference on Computer Graphics}, 82 | series = {SCCG '14}, 83 | year = {2014}, 84 | isbn = {978-1-4503-3070-1}, 85 | location = {Smolenice, Slovakia}, 86 | pages = {29--36}, 87 | numpages = {8}, 88 | doi = {10.1145/2643188.2643196}, 89 | acmid = {2643196}, 90 | publisher = {ACM}, 91 | address = {New York, NY, USA} 92 | } 93 | 94 | @article {Bittner2015, 95 | title = "Incremental BVH construction for ray tracing", 96 | journal = "Computers \& Graphics", 97 | volume = "47", 98 | pages = "135 - 144", 99 | year = "2015", 100 | author = "Jiří Bittner and Michal Hapala and Vlastimil Havran" 101 | } 102 | 103 | @misc {Presson2008, 104 | title = {Bullet Physics Dynamic Tree}, 105 | author = {Nathaniel Presson}, 106 | howpublished = {\url{http://bulletphysics.org}} 107 | } 108 | 109 | @misc {Catto2019, 110 | author = {Erin Catto}, 111 | title = {dynamic-tree}, 112 | year = {2019}, 113 | howpublished = "\url{https://github.com/erincatto/dynamic-tree}" 114 | } 115 | -------------------------------------------------------------------------------- /docs/Erin Catto - Dynamic BVH GDC.pptx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4627124b770037a552370ae1f2861ccb30d9d493e7caf8816507f136823fafa3 3 | size 13580260 4 | -------------------------------------------------------------------------------- /docs/Erin Catto - Dynamic BVH.pptx: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:89b0fe23d1e1f605dccd6954854c472b2d9f44c11a30525769316d520c577bbc 3 | size 13781442 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardLand1000_BottomUp.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6b23f30a5ac090bc9bc7a65baf27f9d45d8e400fec7f1aa96dd8379bb0eca7f2 3 | size 9508 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardWorld.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3692efc662ba03e1d2ac388650588f3df27f6e5119747709ca40a842434892ef 3 | size 2846128 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardWorldBalloons.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:065bee9b494dd7dd39f6e40beeb21be0f58262df3b115bb50f5caae958e0b2b7 3 | size 3833449 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardWorldBoxes.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:29f041eb1f68b8506644a9db5d71c2377d3d4791a17bf5e22dddc6920a07ccd5 3 | size 226870 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardWorldOverlayBoxes.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c9624493d5eb3c9d90deccb6d94aa3c7d7c1ba6f3be8276ba604b0c5e34216a2 3 | size 2850851 4 | -------------------------------------------------------------------------------- /docs/images/BlizzardWorldZoomed.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f82ecc82c400bd2487b7d8895c4c1eb51a32818e1e57a7c062dc3585f5031130 3 | size 229615 4 | -------------------------------------------------------------------------------- /docs/images/BulletTiles.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4ac1c26f4aaf163e0bb8701b203b1f1f4ead9ca85e6324f59f827ce3730911a5 3 | size 125258 4 | -------------------------------------------------------------------------------- /docs/images/InflatedAABBs.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 42 | 47 | 48 | 50 | 51 | 53 | image/svg+xml 54 | 56 | 57 | 58 | 59 | 60 | 65 | 70 | 76 | 82 | 89 | 96 | 103 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /docs/images/LooseObjects.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 41 | 46 | 47 | 49 | 50 | 52 | image/svg+xml 53 | 55 | 56 | 57 | 58 | 59 | 64 | 70 | 76 | 81 | 86 | 92 | 98 | 104 | 110 | 116 | 122 | 127 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /docs/images/LooseOverlap.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 41 | 46 | 47 | 49 | 50 | 52 | image/svg+xml 53 | 55 | 56 | 57 | 58 | 59 | 64 | 70 | 76 | 81 | 86 | 92 | 98 | 104 | 110 | 116 | 122 | 127 | 133 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /docs/images/Pyramid.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:951d3e4351c9f21008f9e615a2b6298fddf5c6b370041fd155883708cdd484e3 3 | size 19870 4 | -------------------------------------------------------------------------------- /docs/images/SingleLeaf.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 50 | 55 | 56 | 58 | 59 | 61 | image/svg+xml 62 | 64 | 65 | 66 | 67 | 68 | 73 | 79 | 85 | 91 | 98 | Q 108 | P 116 | G 126 | 134 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /docs/images/TiledBottomUp.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:040d46b087140fd546c8ab01b2bf205eb8d8c4bb36be0d37f3419454550229ce 3 | size 9695 4 | -------------------------------------------------------------------------------- /docs/images/Tiles.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:67c1851bacbc9c281167301eb30641bc5d56c294db997cbc0295f7aad94af170 3 | size 16832 4 | -------------------------------------------------------------------------------- /docs/images/minecraft.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6ce1424192c20050b1abbde3fbd72a2bee544914d2084d3fde395c806c851065 3 | size 1477440 4 | -------------------------------------------------------------------------------- /docs/images/sort_balanced.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | %3 11 | 12 | 13 | 0 14 | 15 | A 16 | 17 | 18 | 1 19 | 20 | B 21 | 22 | 23 | 2 24 | 25 | 26 | 27 | 6 28 | 29 | 30 | 31 | 2--6 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 39 | 2--10 40 | 41 | 42 | 43 | 3 44 | 45 | C 46 | 47 | 48 | 4 49 | 50 | 51 | 52 | 4--0 53 | 54 | 55 | 56 | 4--1 57 | 58 | 59 | 60 | 5 61 | 62 | D 63 | 64 | 65 | 6--4 66 | 67 | 68 | 69 | 8 70 | 71 | 72 | 73 | 6--8 74 | 75 | 76 | 77 | 7 78 | 79 | E 80 | 81 | 82 | 8--3 83 | 84 | 85 | 86 | 8--5 87 | 88 | 89 | 90 | 9 91 | 92 | F 93 | 94 | 95 | 12 96 | 97 | 98 | 99 | 10--12 100 | 101 | 102 | 103 | 14 104 | 105 | 106 | 107 | 10--14 108 | 109 | 110 | 111 | 11 112 | 113 | G 114 | 115 | 116 | 12--7 117 | 118 | 119 | 120 | 12--9 121 | 122 | 123 | 124 | 13 125 | 126 | H 127 | 128 | 129 | 14--11 130 | 131 | 132 | 133 | 14--13 134 | 135 | 136 | 137 | 16 138 | 139 | area ratio = 2.24 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /docs/images/sort_linked.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | %3 11 | 12 | 13 | 0 14 | 15 | A 16 | 17 | 18 | 1 19 | 20 | B 21 | 22 | 23 | 2 24 | 25 | 26 | 27 | 2--0 28 | 29 | 30 | 31 | 4 32 | 33 | 34 | 35 | 2--4 36 | 37 | 38 | 39 | 3 40 | 41 | C 42 | 43 | 44 | 4--1 45 | 46 | 47 | 48 | 6 49 | 50 | 51 | 52 | 4--6 53 | 54 | 55 | 56 | 5 57 | 58 | D 59 | 60 | 61 | 6--3 62 | 63 | 64 | 65 | 8 66 | 67 | 68 | 69 | 6--8 70 | 71 | 72 | 73 | 7 74 | 75 | E 76 | 77 | 78 | 8--5 79 | 80 | 81 | 82 | 10 83 | 84 | 85 | 86 | 8--10 87 | 88 | 89 | 90 | 9 91 | 92 | F 93 | 94 | 95 | 10--7 96 | 97 | 98 | 99 | 12 100 | 101 | 102 | 103 | 10--12 104 | 105 | 106 | 107 | 11 108 | 109 | G 110 | 111 | 112 | 12--9 113 | 114 | 115 | 116 | 14 117 | 118 | 119 | 120 | 12--14 121 | 122 | 123 | 124 | 13 125 | 126 | H 127 | 128 | 129 | 14--11 130 | 131 | 132 | 133 | 14--13 134 | 135 | 136 | 137 | 16 138 | 139 | area ratio = 3.53 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /docs/images/terraria.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9ae93efc020144f2f2d62dca22ce8d9fc8fbe4e924445e39f098d5a1957d128c 3 | size 362928 4 | -------------------------------------------------------------------------------- /docs/refs/A. Kensler - Tree Rotations for Improving Bounding Volume Hierarchies.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c8f07927d0152e98830bb0cd1ea8a164c27b460ef9ee61dc6035ef8868722447 3 | size 2254505 4 | -------------------------------------------------------------------------------- /docs/refs/D. Kopta - Fast, Effective BVH Updates for Animated Scenes.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d8fae4a104543f710c0c9ff1cd10cd5cd5e1062317403a7dc2b97b6897a0af56 3 | size 7247032 4 | -------------------------------------------------------------------------------- /docs/refs/G. van den Bergen - Efficient Collision Detection of Complex Deformable Models.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6c9d3a0c02e54fc82f75e843e6f3a0ef6097b3834d7b88745e133edc73050f9e 3 | size 179136 4 | -------------------------------------------------------------------------------- /docs/refs/I. Wald - Ray Tracing Deformable Scenes.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2de46b50789b56eabbdb06bc9aa243ae285bb2da302c22736877bec9708f0534 3 | size 17931355 4 | -------------------------------------------------------------------------------- /docs/refs/J. Bittner - Fast Insertion-Based Optimization.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fcfaa4b666be2dbc7b046b7cd25710b9d44ebe46b2f648b2523e8cbd69053d9f 3 | size 2005835 4 | -------------------------------------------------------------------------------- /docs/refs/J. Bittner - Incremental BVH Construction for Ray Tracing.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3e3f101b69f6f6401e74bcd804660328ae4beb763fc4ee38bc68903bc1fa9254 3 | size 3090506 4 | -------------------------------------------------------------------------------- /docs/refs/J. Goldsmith - Automatic Creation of Object Hierarchies.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3278ca15c9e6965aee09ef447086d00e2cf0f938b0443b56edd47b312e536a60 3 | size 1338610 4 | -------------------------------------------------------------------------------- /docs/refs/M. Otaguy - Balanced Hierarchies for Collision Detection.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:145bcb692d304ab44d80df8319c149e1c7ba689b51451817a32623134ead772b 3 | size 1573549 4 | -------------------------------------------------------------------------------- /docs/refs/Notes.md: -------------------------------------------------------------------------------- 1 | # J. Goldsmith (1987) - Automatic Creation of Object Hierarchies 2 | Orignal SAH paper. SAH insertion BVH build. Handles case where new leaf is fully contained by two child nodes: 3 | - search both 4 | - choose closest center 5 | Considered insertion order. Found orderd insertion is bad (e.g. tile-based worlds, checker board) 6 | Funny: written before the term AABB existed. 7 | 8 | # S. Omohundro (1989) - Five Balltree Construction Algorithms 9 | Considers top down, bottom up, and incremental tree building algorithms. Minimizing volume. 10 | 11 | # G. van den Bergen (1998) - Efficient Collision Detection of Complex Deformable Models using AABB Trees 12 | 13 | mid-point splits, binary, refits. Unaware of SAH. 14 | 15 | # T. Larsson (2006) - A Dynamic Bounding Volume Hierarchy for Generalized Collision Detection 16 | 17 | AABB tree, Mid-point splits, 8-ary with culling, refits, rebuilds sub-trees, lazy update. Rules out multithreaded queries. Uses volume heuristic. Unaware of SAH. 18 | 19 | # M. Otaduy (2007) - Balanced Hierarchies for Collision Detection between Fracturing Objects 20 | 21 | median splits, balanced tree, AVL rotations for rebalancing when adding/removing triangles, grandchildren permutation to optimize squared volume heuristic. Unaware of SAH. 22 | 23 | # A. Kensler (2008) - Tree Rotations for Improving Bounding Volume Hierarchies 24 | 25 | Original rotation idea. Used hill climbing and simulated annealing to apply rotations to improve tree quality 26 | 27 | # D. Kopta (with A. Kensler) (2012) - Fast, Effective BVH Updates for Animated Scenes 28 | 29 | Rotations applied on animating scenes. Refit and rotations applied accross whole tree each frame. 30 | 31 | # J. Bittner (2013) - Fast Insertion-Based Optimization of Bounding Volume Hierarchies 32 | 33 | takes existing BVH and removes a node and re-inserts sub-trees. Uses SAH inheritance cost to find insertion. Uses priority queue (branch and bound) method to find optimial sibling. Node removal based on (node area) * (node area / smallest child area) * (node area / sum child area). Builds tree one triangle per leaf then collapses several triangles under a subtree to minimize SAH. 34 | 35 | # J. Bittner (2015) - Incremental BVH Construction for Ray Tracing 36 | 37 | SAH BVH insertion build. Search for best insertion via branch and bound with priority queue. 38 | Incremental optimization by node removal and re-insertion in batches. Removals restricted to region of tree that had insertions. Similar to Bittner 2013. 39 | 40 | # Nathanael Presson, btDbvt 41 | 42 | Incremental BVH builder. Uses Manhattan distance of centers for insertion traversal. Only considers leaves as siblings. Tiles example creates tree of height 209. Takes 49300 iterations to get to height of 14 using round-robbin remove-insert. -------------------------------------------------------------------------------- /docs/refs/S. Omohundro - Five Balltree Construction Algorithms.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7cbb5408f8d05794fc3a597de4a28c682a4bf6cf6ff2fe98e117d5768d1d0bee 3 | size 296321 4 | -------------------------------------------------------------------------------- /docs/refs/T. Larsson - A Dynamic Bounding Volume Hierarchy.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:81e38bedbd83a4200035976eba6a3f9d5c47f351d33267db10353e62d3b9ed14 3 | size 1043435 4 | -------------------------------------------------------------------------------- /extern/dbvt/btDbvt_orig.h: -------------------------------------------------------------------------------- 1 | /* 2 | Bounding Volume Hierarchy, btDbvt.h 3 | Copyright (c) 2008 Nathanael Presson, as part of Bullet Physics Library 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it freely, 9 | subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 | 3. This notice may not be removed or altered from any source distribution. 14 | */ 15 | 16 | #ifndef _6095FD2A_2B3C_4c47_AB85_D56C1DD1A210_ 17 | #define _6095FD2A_2B3C_4c47_AB85_D56C1DD1A210_ 18 | 19 | #include "LinearMath/btAlignedObjectArray.h" 20 | #include "LinearMath/btPoint3.h" 21 | #include "LinearMath/btTransform.h" 22 | #include "LinearMath/btIDebugDraw.h" 23 | 24 | // 25 | // Dynamic bounding volume tree 26 | // 27 | struct btDbvt 28 | { 29 | // Types 30 | 31 | /* AabbCe */ 32 | struct Aabb 33 | { 34 | btVector3 mi,mx; 35 | inline btVector3 Center() const { return((mi+mx)/2); } 36 | inline btVector3 Extent() const { return((mx-mi)/2); } 37 | static inline Aabb FromCE(const btVector3& c,const btVector3& e) 38 | { 39 | Aabb box; 40 | box.mi=c-e;box.mx=c+e; 41 | return(box); 42 | } 43 | inline friend bool operator==(const Aabb& a,const Aabb& b) 44 | { 45 | return( ((a.mi-b.mi).length2()==0)&& 46 | ((a.mx-b.mx).length2()==0)); 47 | } 48 | }; 49 | /* Node */ 50 | struct Node 51 | { 52 | Aabb box; 53 | Node* parent; 54 | bool isleaf() const { return(childs[1]==0); } 55 | bool isinternal() const { return(!isleaf()); } 56 | union { 57 | Node* childs[2]; 58 | void* data; 59 | }; 60 | }; 61 | // Fields 62 | Node* m_root; 63 | Node* m_stock; 64 | int m_nleafs; 65 | // Methods 66 | static btDbvt* Create(); 67 | void Delete(); 68 | void OptimizeBottomUp(); 69 | void OptimizeTopDown(); 70 | Node* Insert( const btVector3& center, 71 | const btVector3& extent, 72 | void* data); 73 | bool Update( Node* leaf, 74 | const btVector3& center, 75 | const btVector3& extent, 76 | btScalar margin=0); 77 | void Remove( Node* leaf); 78 | // Inline's 79 | inline Node* Insert( const btVector3& center, 80 | btScalar radius, 81 | void* data) 82 | { 83 | return(Insert(center,btVector3(radius,radius,radius),data)); 84 | } 85 | bool Update( Node* leaf, 86 | const btVector3& center, 87 | btScalar radius, 88 | btScalar margin=0) 89 | { 90 | return(Update(leaf,center,btVector3(radius,radius,radius),margin)); 91 | } 92 | }; 93 | 94 | #endif -------------------------------------------------------------------------------- /extern/glfw/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(glfw C) 2 | 3 | find_package(Threads REQUIRED) 4 | 5 | # Establish target libraries and include directories 6 | if (APPLE) 7 | 8 | list(APPEND glfw_LIBRARIES 9 | "-framework Cocoa" 10 | "-framework IOKit" 11 | "-framework CoreFoundation" 12 | "-framework CoreVideo") 13 | 14 | elseif (UNIX) 15 | find_library(RT_LIBRARY rt) 16 | if (RT_LIBRARY) 17 | list(APPEND glfw_LIBRARIES "${RT_LIBRARY}") 18 | endif() 19 | 20 | find_library(MATH_LIBRARY m) 21 | if (MATH_LIBRARY) 22 | list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") 23 | endif() 24 | 25 | if (CMAKE_DL_LIBS) 26 | list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}") 27 | endif() 28 | 29 | find_package(X11 REQUIRED) 30 | 31 | # Set up library and include paths 32 | list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") 33 | list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}") 34 | 35 | # Check for XRandR (modern resolution switching and gamma control) 36 | if (NOT X11_Xrandr_FOUND) 37 | message(FATAL_ERROR "The RandR headers were not found") 38 | endif() 39 | 40 | # Check for Xinerama (legacy multi-monitor support) 41 | if (NOT X11_Xinerama_FOUND) 42 | message(FATAL_ERROR "The Xinerama headers were not found") 43 | endif() 44 | 45 | # Check for Xkb (X keyboard extension) 46 | if (NOT X11_Xkb_FOUND) 47 | message(FATAL_ERROR "The X keyboard extension headers were not found") 48 | endif() 49 | 50 | # Check for Xcursor (cursor creation from RGBA images) 51 | if (NOT X11_Xcursor_FOUND) 52 | message(FATAL_ERROR "The Xcursor headers were not found") 53 | endif() 54 | 55 | list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}" 56 | "${X11_Xinerama_INCLUDE_PATH}" 57 | "${X11_Xkb_INCLUDE_PATH}" 58 | "${X11_Xcursor_INCLUDE_PATH}") 59 | endif() 60 | 61 | set(common_HEADERS src/internal.h src/mappings.h 62 | include/GLFW/glfw3.h 63 | include/GLFW/glfw3native.h) 64 | set(common_SOURCES src/context.c src/init.c src/input.c src/monitor.c src/vulkan.c src/window.c) 65 | 66 | if (APPLE) 67 | set(glfw_HEADERS ${common_HEADERS} src/cocoa_platform.h src/cocoa_joystick.h 68 | src/posix_thread.h src/nsgl_context.h src/egl_context.h src/osmesa_context.h) 69 | set(glfw_SOURCES ${common_SOURCES} src/cocoa_init.m src/cocoa_joystick.m 70 | src/cocoa_monitor.m src/cocoa_window.m src/cocoa_time.c src/posix_thread.c 71 | src/nsgl_context.m src/egl_context.c src/osmesa_context.c) 72 | set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) 73 | elseif (WIN32) 74 | set(glfw_HEADERS ${common_HEADERS} src/win32_platform.h src/win32_joystick.h 75 | src/wgl_context.h src/egl_context.h src/osmesa_context.h) 76 | set(glfw_SOURCES ${common_SOURCES} src/win32_init.c src/win32_joystick.c 77 | src/win32_monitor.c src/win32_time.c src/win32_thread.c src/win32_window.c 78 | src/wgl_context.c src/egl_context.c src/osmesa_context.c) 79 | elseif (UNIX) 80 | set(glfw_HEADERS ${common_HEADERS} src/x11_platform.h src/xkb_unicode.h src/posix_time.h 81 | src/posix_thread.h src/glx_context.h src/egl_context.h src/osmesa_context.h) 82 | set(glfw_SOURCES ${common_SOURCES} src/x11_init.c src/x11_monitor.c src/x11_window.c 83 | src/xkb_unicode.c src/posix_time.c src/posix_thread.c src/glx_context.c 84 | src/egl_context.c src/osmesa_context.c) 85 | set(glfw_HEADERS ${glfw_HEADERS} src/linux_joystick.h) 86 | set(glfw_SOURCES ${glfw_SOURCES} src/linux_joystick.c) 87 | endif() 88 | 89 | add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) 90 | target_include_directories(glfw PUBLIC include) 91 | target_include_directories(glfw PRIVATE ${glfw_INCLUDE_DIRS}) 92 | target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) 93 | -------------------------------------------------------------------------------- /extern/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | 48 | void _glfwInitJoysticksNS(void); 49 | void _glfwTerminateJoysticksNS(void); 50 | 51 | -------------------------------------------------------------------------------- /extern/glfw/src/cocoa_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #if defined(__OBJC__) 32 | #import 33 | #else 34 | typedef void* id; 35 | #endif 36 | 37 | typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; 38 | 39 | typedef struct VkMacOSSurfaceCreateInfoMVK 40 | { 41 | VkStructureType sType; 42 | const void* pNext; 43 | VkMacOSSurfaceCreateFlagsMVK flags; 44 | const void* pView; 45 | } VkMacOSSurfaceCreateInfoMVK; 46 | 47 | typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); 48 | 49 | #include "posix_thread.h" 50 | #include "cocoa_joystick.h" 51 | #include "nsgl_context.h" 52 | #include "egl_context.h" 53 | #include "osmesa_context.h" 54 | 55 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 56 | #define _glfw_dlclose(handle) dlclose(handle) 57 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 58 | 59 | #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view) 60 | #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY 61 | 62 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns 63 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns 64 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns 65 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns 66 | #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns 67 | 68 | // HIToolbox.framework pointer typedefs 69 | #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData 70 | typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); 71 | #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource 72 | typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); 73 | #define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty 74 | typedef UInt8 (*PFN_LMGetKbdType)(void); 75 | #define LMGetKbdType _glfw.ns.tis.GetKbdType 76 | 77 | 78 | // Cocoa-specific per-window data 79 | // 80 | typedef struct _GLFWwindowNS 81 | { 82 | id object; 83 | id delegate; 84 | id view; 85 | id layer; 86 | 87 | GLFWbool maximized; 88 | 89 | // Cached window properties to filter out duplicate events 90 | int width, height; 91 | int fbWidth, fbHeight; 92 | float xscale, yscale; 93 | 94 | // The total sum of the distances the cursor has been warped 95 | // since the last cursor motion event was processed 96 | // This is kept to counteract Cocoa doing the same internally 97 | double cursorWarpDeltaX, cursorWarpDeltaY; 98 | 99 | } _GLFWwindowNS; 100 | 101 | // Cocoa-specific global data 102 | // 103 | typedef struct _GLFWlibraryNS 104 | { 105 | CGEventSourceRef eventSource; 106 | id delegate; 107 | id autoreleasePool; 108 | GLFWbool cursorHidden; 109 | TISInputSourceRef inputSource; 110 | IOHIDManagerRef hidManager; 111 | id unicodeData; 112 | id helper; 113 | id keyUpMonitor; 114 | id nibObjects; 115 | 116 | char keyName[64]; 117 | short int keycodes[256]; 118 | short int scancodes[GLFW_KEY_LAST + 1]; 119 | char* clipboardString; 120 | CGPoint cascadePoint; 121 | // Where to place the cursor when re-enabled 122 | double restoreCursorPosX, restoreCursorPosY; 123 | // The window whose disabled cursor mode is active 124 | _GLFWwindow* disabledCursorWindow; 125 | 126 | struct { 127 | CFBundleRef bundle; 128 | PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource; 129 | PFN_TISGetInputSourceProperty GetInputSourceProperty; 130 | PFN_LMGetKbdType GetKbdType; 131 | CFStringRef kPropertyUnicodeKeyLayoutData; 132 | } tis; 133 | 134 | } _GLFWlibraryNS; 135 | 136 | // Cocoa-specific per-monitor data 137 | // 138 | typedef struct _GLFWmonitorNS 139 | { 140 | CGDirectDisplayID displayID; 141 | CGDisplayModeRef previousMode; 142 | uint32_t unitNumber; 143 | id screen; 144 | 145 | } _GLFWmonitorNS; 146 | 147 | // Cocoa-specific per-cursor data 148 | // 149 | typedef struct _GLFWcursorNS 150 | { 151 | id object; 152 | 153 | } _GLFWcursorNS; 154 | 155 | // Cocoa-specific global timer data 156 | // 157 | typedef struct _GLFWtimerNS 158 | { 159 | uint64_t frequency; 160 | 161 | } _GLFWtimerNS; 162 | 163 | 164 | void _glfwInitTimerNS(void); 165 | 166 | void _glfwPollMonitorsNS(void); 167 | void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); 168 | void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); 169 | 170 | -------------------------------------------------------------------------------- /extern/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW internal API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Initialise timer 37 | // 38 | void _glfwInitTimerNS(void) 39 | { 40 | mach_timebase_info_data_t info; 41 | mach_timebase_info(&info); 42 | 43 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 44 | } 45 | 46 | 47 | ////////////////////////////////////////////////////////////////////////// 48 | ////// GLFW platform API ////// 49 | ////////////////////////////////////////////////////////////////////////// 50 | 51 | uint64_t _glfwPlatformGetTimerValue(void) 52 | { 53 | return mach_absolute_time(); 54 | } 55 | 56 | uint64_t _glfwPlatformGetTimerFrequency(void) 57 | { 58 | return _glfw.timer.ns.frequency; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /extern/glfw/src/glfw_config.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // MODIFIED_ERIN 38 | #ifdef _WIN32 39 | #define _GLFW_WIN32 40 | #define _CRT_SECURE_NO_WARNINGS 41 | #elif __APPLE__ 42 | #define _GLFW_COCOA 43 | #else 44 | #define _GLFW_X11 45 | #endif 46 | -------------------------------------------------------------------------------- /extern/glfw/src/glx_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 GLX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define GLX_VENDOR 1 29 | #define GLX_RGBA_BIT 0x00000001 30 | #define GLX_WINDOW_BIT 0x00000001 31 | #define GLX_DRAWABLE_TYPE 0x8010 32 | #define GLX_RENDER_TYPE 0x8011 33 | #define GLX_RGBA_TYPE 0x8014 34 | #define GLX_DOUBLEBUFFER 5 35 | #define GLX_STEREO 6 36 | #define GLX_AUX_BUFFERS 7 37 | #define GLX_RED_SIZE 8 38 | #define GLX_GREEN_SIZE 9 39 | #define GLX_BLUE_SIZE 10 40 | #define GLX_ALPHA_SIZE 11 41 | #define GLX_DEPTH_SIZE 12 42 | #define GLX_STENCIL_SIZE 13 43 | #define GLX_ACCUM_RED_SIZE 14 44 | #define GLX_ACCUM_GREEN_SIZE 15 45 | #define GLX_ACCUM_BLUE_SIZE 16 46 | #define GLX_ACCUM_ALPHA_SIZE 17 47 | #define GLX_SAMPLES 0x186a1 48 | #define GLX_VISUAL_ID 0x800b 49 | 50 | #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 51 | #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 52 | #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 53 | #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 54 | #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 55 | #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 56 | #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 57 | #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 58 | #define GLX_CONTEXT_FLAGS_ARB 0x2094 59 | #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 60 | #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 61 | #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 62 | #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 63 | #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 64 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 65 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 66 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 67 | #define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 68 | 69 | typedef XID GLXWindow; 70 | typedef XID GLXDrawable; 71 | typedef struct __GLXFBConfig* GLXFBConfig; 72 | typedef struct __GLXcontext* GLXContext; 73 | typedef void (*__GLXextproc)(void); 74 | 75 | typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*); 76 | typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int); 77 | typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*); 78 | typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*); 79 | typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext); 80 | typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext); 81 | typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable); 82 | typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int); 83 | typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*); 84 | typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool); 85 | typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName); 86 | typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int); 87 | typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig); 88 | typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*); 89 | typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); 90 | 91 | typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); 92 | typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int); 93 | typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*); 94 | 95 | // libGL.so function pointer typedefs 96 | #define glXGetFBConfigs _glfw.glx.GetFBConfigs 97 | #define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib 98 | #define glXGetClientString _glfw.glx.GetClientString 99 | #define glXQueryExtension _glfw.glx.QueryExtension 100 | #define glXQueryVersion _glfw.glx.QueryVersion 101 | #define glXDestroyContext _glfw.glx.DestroyContext 102 | #define glXMakeCurrent _glfw.glx.MakeCurrent 103 | #define glXSwapBuffers _glfw.glx.SwapBuffers 104 | #define glXQueryExtensionsString _glfw.glx.QueryExtensionsString 105 | #define glXCreateNewContext _glfw.glx.CreateNewContext 106 | #define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig 107 | #define glXCreateWindow _glfw.glx.CreateWindow 108 | #define glXDestroyWindow _glfw.glx.DestroyWindow 109 | 110 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx 111 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx 112 | 113 | 114 | // GLX-specific per-context data 115 | // 116 | typedef struct _GLFWcontextGLX 117 | { 118 | GLXContext handle; 119 | GLXWindow window; 120 | 121 | } _GLFWcontextGLX; 122 | 123 | // GLX-specific global data 124 | // 125 | typedef struct _GLFWlibraryGLX 126 | { 127 | int major, minor; 128 | int eventBase; 129 | int errorBase; 130 | 131 | // dlopen handle for libGL.so.1 132 | void* handle; 133 | 134 | // GLX 1.3 functions 135 | PFNGLXGETFBCONFIGSPROC GetFBConfigs; 136 | PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib; 137 | PFNGLXGETCLIENTSTRINGPROC GetClientString; 138 | PFNGLXQUERYEXTENSIONPROC QueryExtension; 139 | PFNGLXQUERYVERSIONPROC QueryVersion; 140 | PFNGLXDESTROYCONTEXTPROC DestroyContext; 141 | PFNGLXMAKECURRENTPROC MakeCurrent; 142 | PFNGLXSWAPBUFFERSPROC SwapBuffers; 143 | PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString; 144 | PFNGLXCREATENEWCONTEXTPROC CreateNewContext; 145 | PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig; 146 | PFNGLXCREATEWINDOWPROC CreateWindow; 147 | PFNGLXDESTROYWINDOWPROC DestroyWindow; 148 | 149 | // GLX 1.4 and extension functions 150 | PFNGLXGETPROCADDRESSPROC GetProcAddress; 151 | PFNGLXGETPROCADDRESSPROC GetProcAddressARB; 152 | PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; 153 | PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; 154 | PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; 155 | PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 156 | GLFWbool SGI_swap_control; 157 | GLFWbool EXT_swap_control; 158 | GLFWbool MESA_swap_control; 159 | GLFWbool ARB_multisample; 160 | GLFWbool ARB_framebuffer_sRGB; 161 | GLFWbool EXT_framebuffer_sRGB; 162 | GLFWbool ARB_create_context; 163 | GLFWbool ARB_create_context_profile; 164 | GLFWbool ARB_create_context_robustness; 165 | GLFWbool EXT_create_context_es2_profile; 166 | GLFWbool ARB_create_context_no_error; 167 | GLFWbool ARB_context_flush_control; 168 | 169 | } _GLFWlibraryGLX; 170 | 171 | GLFWbool _glfwInitGLX(void); 172 | void _glfwTerminateGLX(void); 173 | GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, 174 | const _GLFWctxconfig* ctxconfig, 175 | const _GLFWfbconfig* fbconfig); 176 | void _glfwDestroyContextGLX(_GLFWwindow* window); 177 | GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, 178 | const _GLFWctxconfig* ctxconfig, 179 | const _GLFWfbconfig* fbconfig, 180 | Visual** visual, int* depth); 181 | 182 | -------------------------------------------------------------------------------- /extern/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | 59 | GLFWbool _glfwInitJoysticksLinux(void); 60 | void _glfwTerminateJoysticksLinux(void); 61 | void _glfwDetectJoystickConnectionLinux(void); 62 | 63 | -------------------------------------------------------------------------------- /extern/glfw/src/mappings.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As mappings.h.in, this file is used by CMake to produce the mappings.h 27 | // header file. If you are adding a GLFW specific gamepad mapping, this is 28 | // where to put it. 29 | //======================================================================== 30 | // As mappings.h, this provides all pre-defined gamepad mappings, including 31 | // all available in SDL_GameControllerDB. Do not edit this file. Any gamepad 32 | // mappings not specific to GLFW should be submitted to SDL_GameControllerDB. 33 | // This file can be re-generated from mappings.h.in and the upstream 34 | // gamecontrollerdb.txt with the GenerateMappings.cmake script. 35 | //======================================================================== 36 | 37 | // All gamepad mappings not labeled GLFW are copied from the 38 | // SDL_GameControllerDB project under the following license: 39 | // 40 | // Simple DirectMedia Layer 41 | // Copyright (C) 1997-2013 Sam Lantinga 42 | // 43 | // This software is provided 'as-is', without any express or implied warranty. 44 | // In no event will the authors be held liable for any damages arising from the 45 | // use of this software. 46 | // 47 | // Permission is granted to anyone to use this software for any purpose, 48 | // including commercial applications, and to alter it and redistribute it 49 | // freely, subject to the following restrictions: 50 | // 51 | // 1. The origin of this software must not be misrepresented; you must not 52 | // claim that you wrote the original software. If you use this software 53 | // in a product, an acknowledgment in the product documentation would 54 | // be appreciated but is not required. 55 | // 56 | // 2. Altered source versions must be plainly marked as such, and must not be 57 | // misrepresented as being the original software. 58 | // 59 | // 3. This notice may not be removed or altered from any source distribution. 60 | 61 | const char* _glfwDefaultMappings[] = 62 | { 63 | @GLFW_GAMEPAD_MAPPINGS@ 64 | "78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 65 | "78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 66 | "78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 67 | "78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 68 | "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 69 | "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 70 | "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 71 | NULL 72 | }; 73 | 74 | -------------------------------------------------------------------------------- /extern/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 28 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 29 | 30 | 31 | // NSGL-specific per-context data 32 | // 33 | typedef struct _GLFWcontextNSGL 34 | { 35 | id pixelFormat; 36 | id object; 37 | 38 | } _GLFWcontextNSGL; 39 | 40 | // NSGL-specific global data 41 | // 42 | typedef struct _GLFWlibraryNSGL 43 | { 44 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 45 | CFBundleRef framework; 46 | 47 | } _GLFWlibraryNSGL; 48 | 49 | 50 | GLFWbool _glfwInitNSGL(void); 51 | void _glfwTerminateNSGL(void); 52 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 53 | const _GLFWctxconfig* ctxconfig, 54 | const _GLFWfbconfig* fbconfig); 55 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 56 | 57 | -------------------------------------------------------------------------------- /extern/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW platform API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | int _glfwPlatformInit(void) 36 | { 37 | _glfwInitTimerPOSIX(); 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminate(void) 42 | { 43 | _glfwTerminateOSMesa(); 44 | } 45 | 46 | const char* _glfwPlatformGetVersionString(void) 47 | { 48 | return _GLFW_VERSION_NUMBER " null OSMesa"; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /extern/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | 30 | ////////////////////////////////////////////////////////////////////////// 31 | ////// GLFW platform API ////// 32 | ////////////////////////////////////////////////////////////////////////// 33 | 34 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 35 | { 36 | return GLFW_FALSE; 37 | } 38 | 39 | void _glfwPlatformUpdateGamepadGUID(char* guid) 40 | { 41 | } 42 | 43 | -------------------------------------------------------------------------------- /extern/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /extern/glfw/src/null_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW platform API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) 36 | { 37 | } 38 | 39 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 40 | { 41 | } 42 | 43 | void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, 44 | float* xscale, float* yscale) 45 | { 46 | if (xscale) 47 | *xscale = 1.f; 48 | if (yscale) 49 | *yscale = 1.f; 50 | } 51 | 52 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 53 | { 54 | return NULL; 55 | } 56 | 57 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 58 | { 59 | } 60 | 61 | GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 62 | { 63 | return GLFW_FALSE; 64 | } 65 | 66 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 67 | { 68 | } 69 | 70 | -------------------------------------------------------------------------------- /extern/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | 32 | #define _GLFW_PLATFORM_CONTEXT_STATE 33 | #define _GLFW_PLATFORM_MONITOR_STATE 34 | #define _GLFW_PLATFORM_CURSOR_STATE 35 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE 37 | #define _GLFW_EGL_CONTEXT_STATE 38 | #define _GLFW_EGL_LIBRARY_CONTEXT_STATE 39 | 40 | #include "osmesa_context.h" 41 | #include "posix_time.h" 42 | #include "posix_thread.h" 43 | #include "null_joystick.h" 44 | 45 | #if defined(_GLFW_WIN32) 46 | #define _glfw_dlopen(name) LoadLibraryA(name) 47 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 48 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 49 | #else 50 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 51 | #define _glfw_dlclose(handle) dlclose(handle) 52 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 53 | #endif 54 | 55 | // Null-specific per-window data 56 | // 57 | typedef struct _GLFWwindowNull 58 | { 59 | int width; 60 | int height; 61 | } _GLFWwindowNull; 62 | 63 | -------------------------------------------------------------------------------- /extern/glfw/src/osmesa_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 OSMesa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define OSMESA_RGBA 0x1908 29 | #define OSMESA_FORMAT 0x22 30 | #define OSMESA_DEPTH_BITS 0x30 31 | #define OSMESA_STENCIL_BITS 0x31 32 | #define OSMESA_ACCUM_BITS 0x32 33 | #define OSMESA_PROFILE 0x33 34 | #define OSMESA_CORE_PROFILE 0x34 35 | #define OSMESA_COMPAT_PROFILE 0x35 36 | #define OSMESA_CONTEXT_MAJOR_VERSION 0x36 37 | #define OSMESA_CONTEXT_MINOR_VERSION 0x37 38 | 39 | typedef void* OSMesaContext; 40 | typedef void (*OSMESAproc)(void); 41 | 42 | typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); 43 | typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); 44 | typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); 45 | typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); 46 | typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); 47 | typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); 48 | typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); 49 | #define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt 50 | #define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs 51 | #define OSMesaDestroyContext _glfw.osmesa.DestroyContext 52 | #define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent 53 | #define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer 54 | #define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer 55 | #define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress 56 | 57 | #define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa 58 | #define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa 59 | 60 | 61 | // OSMesa-specific per-context data 62 | // 63 | typedef struct _GLFWcontextOSMesa 64 | { 65 | OSMesaContext handle; 66 | int width; 67 | int height; 68 | void* buffer; 69 | 70 | } _GLFWcontextOSMesa; 71 | 72 | // OSMesa-specific global data 73 | // 74 | typedef struct _GLFWlibraryOSMesa 75 | { 76 | void* handle; 77 | 78 | PFN_OSMesaCreateContextExt CreateContextExt; 79 | PFN_OSMesaCreateContextAttribs CreateContextAttribs; 80 | PFN_OSMesaDestroyContext DestroyContext; 81 | PFN_OSMesaMakeCurrent MakeCurrent; 82 | PFN_OSMesaGetColorBuffer GetColorBuffer; 83 | PFN_OSMesaGetDepthBuffer GetDepthBuffer; 84 | PFN_OSMesaGetProcAddress GetProcAddress; 85 | 86 | } _GLFWlibraryOSMesa; 87 | 88 | 89 | GLFWbool _glfwInitOSMesa(void); 90 | void _glfwTerminateOSMesa(void); 91 | GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, 92 | const _GLFWctxconfig* ctxconfig, 93 | const _GLFWfbconfig* fbconfig); 94 | 95 | -------------------------------------------------------------------------------- /extern/glfw/src/posix_thread.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW platform API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls) 39 | { 40 | assert(tls->posix.allocated == GLFW_FALSE); 41 | 42 | if (pthread_key_create(&tls->posix.key, NULL) != 0) 43 | { 44 | _glfwInputError(GLFW_PLATFORM_ERROR, 45 | "POSIX: Failed to create context TLS"); 46 | return GLFW_FALSE; 47 | } 48 | 49 | tls->posix.allocated = GLFW_TRUE; 50 | return GLFW_TRUE; 51 | } 52 | 53 | void _glfwPlatformDestroyTls(_GLFWtls* tls) 54 | { 55 | if (tls->posix.allocated) 56 | pthread_key_delete(tls->posix.key); 57 | memset(tls, 0, sizeof(_GLFWtls)); 58 | } 59 | 60 | void* _glfwPlatformGetTls(_GLFWtls* tls) 61 | { 62 | assert(tls->posix.allocated == GLFW_TRUE); 63 | return pthread_getspecific(tls->posix.key); 64 | } 65 | 66 | void _glfwPlatformSetTls(_GLFWtls* tls, void* value) 67 | { 68 | assert(tls->posix.allocated == GLFW_TRUE); 69 | pthread_setspecific(tls->posix.key, value); 70 | } 71 | 72 | GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex) 73 | { 74 | assert(mutex->posix.allocated == GLFW_FALSE); 75 | 76 | if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0) 77 | { 78 | _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex"); 79 | return GLFW_FALSE; 80 | } 81 | 82 | return mutex->posix.allocated = GLFW_TRUE; 83 | } 84 | 85 | void _glfwPlatformDestroyMutex(_GLFWmutex* mutex) 86 | { 87 | if (mutex->posix.allocated) 88 | pthread_mutex_destroy(&mutex->posix.handle); 89 | memset(mutex, 0, sizeof(_GLFWmutex)); 90 | } 91 | 92 | void _glfwPlatformLockMutex(_GLFWmutex* mutex) 93 | { 94 | assert(mutex->posix.allocated == GLFW_TRUE); 95 | pthread_mutex_lock(&mutex->posix.handle); 96 | } 97 | 98 | void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) 99 | { 100 | assert(mutex->posix.allocated == GLFW_TRUE); 101 | pthread_mutex_unlock(&mutex->posix.handle); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /extern/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /extern/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerPOSIX(void) 41 | { 42 | #if defined(CLOCK_MONOTONIC) 43 | struct timespec ts; 44 | 45 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 46 | { 47 | _glfw.timer.posix.monotonic = GLFW_TRUE; 48 | _glfw.timer.posix.frequency = 1000000000; 49 | } 50 | else 51 | #endif 52 | { 53 | _glfw.timer.posix.monotonic = GLFW_FALSE; 54 | _glfw.timer.posix.frequency = 1000000; 55 | } 56 | } 57 | 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | ////// GLFW platform API ////// 61 | ////////////////////////////////////////////////////////////////////////// 62 | 63 | uint64_t _glfwPlatformGetTimerValue(void) 64 | { 65 | #if defined(CLOCK_MONOTONIC) 66 | if (_glfw.timer.posix.monotonic) 67 | { 68 | struct timespec ts; 69 | clock_gettime(CLOCK_MONOTONIC, &ts); 70 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 71 | } 72 | else 73 | #endif 74 | { 75 | struct timeval tv; 76 | gettimeofday(&tv, NULL); 77 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 78 | } 79 | } 80 | 81 | uint64_t _glfwPlatformGetTimerFrequency(void) 82 | { 83 | return _glfw.timer.posix.frequency; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /extern/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /extern/glfw/src/wgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 WGL - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 29 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 30 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 31 | #define WGL_PIXEL_TYPE_ARB 0x2013 32 | #define WGL_TYPE_RGBA_ARB 0x202b 33 | #define WGL_ACCELERATION_ARB 0x2003 34 | #define WGL_NO_ACCELERATION_ARB 0x2025 35 | #define WGL_RED_BITS_ARB 0x2015 36 | #define WGL_RED_SHIFT_ARB 0x2016 37 | #define WGL_GREEN_BITS_ARB 0x2017 38 | #define WGL_GREEN_SHIFT_ARB 0x2018 39 | #define WGL_BLUE_BITS_ARB 0x2019 40 | #define WGL_BLUE_SHIFT_ARB 0x201a 41 | #define WGL_ALPHA_BITS_ARB 0x201b 42 | #define WGL_ALPHA_SHIFT_ARB 0x201c 43 | #define WGL_ACCUM_BITS_ARB 0x201d 44 | #define WGL_ACCUM_RED_BITS_ARB 0x201e 45 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201f 46 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 47 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 48 | #define WGL_DEPTH_BITS_ARB 0x2022 49 | #define WGL_STENCIL_BITS_ARB 0x2023 50 | #define WGL_AUX_BUFFERS_ARB 0x2024 51 | #define WGL_STEREO_ARB 0x2012 52 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 53 | #define WGL_SAMPLES_ARB 0x2042 54 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9 55 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 56 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 57 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 58 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 59 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 60 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 61 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 62 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 63 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 64 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 65 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 66 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 67 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 68 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 69 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 70 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 71 | #define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 72 | #define WGL_COLORSPACE_EXT 0x309d 73 | #define WGL_COLORSPACE_SRGB_EXT 0x3089 74 | 75 | #define ERROR_INVALID_VERSION_ARB 0x2095 76 | #define ERROR_INVALID_PROFILE_ARB 0x2096 77 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 78 | 79 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); 80 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); 81 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); 82 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); 83 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); 84 | 85 | typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); 86 | typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC); 87 | typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR); 88 | typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void); 89 | typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void); 90 | typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC); 91 | typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); 92 | 93 | // opengl32.dll function pointer typedefs 94 | #define wglCreateContext _glfw.wgl.CreateContext 95 | #define wglDeleteContext _glfw.wgl.DeleteContext 96 | #define wglGetProcAddress _glfw.wgl.GetProcAddress 97 | #define wglGetCurrentDC _glfw.wgl.GetCurrentDC 98 | #define wglGetCurrentContext _glfw.wgl.GetCurrentContext 99 | #define wglMakeCurrent _glfw.wgl.MakeCurrent 100 | #define wglShareLists _glfw.wgl.ShareLists 101 | 102 | #define _GLFW_RECREATION_NOT_NEEDED 0 103 | #define _GLFW_RECREATION_REQUIRED 1 104 | #define _GLFW_RECREATION_IMPOSSIBLE 2 105 | 106 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl 107 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl 108 | 109 | 110 | // WGL-specific per-context data 111 | // 112 | typedef struct _GLFWcontextWGL 113 | { 114 | HDC dc; 115 | HGLRC handle; 116 | int interval; 117 | 118 | } _GLFWcontextWGL; 119 | 120 | // WGL-specific global data 121 | // 122 | typedef struct _GLFWlibraryWGL 123 | { 124 | HINSTANCE instance; 125 | PFN_wglCreateContext CreateContext; 126 | PFN_wglDeleteContext DeleteContext; 127 | PFN_wglGetProcAddress GetProcAddress; 128 | PFN_wglGetCurrentDC GetCurrentDC; 129 | PFN_wglGetCurrentContext GetCurrentContext; 130 | PFN_wglMakeCurrent MakeCurrent; 131 | PFN_wglShareLists ShareLists; 132 | 133 | PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; 134 | PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; 135 | PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; 136 | PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; 137 | PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 138 | GLFWbool EXT_swap_control; 139 | GLFWbool EXT_colorspace; 140 | GLFWbool ARB_multisample; 141 | GLFWbool ARB_framebuffer_sRGB; 142 | GLFWbool EXT_framebuffer_sRGB; 143 | GLFWbool ARB_pixel_format; 144 | GLFWbool ARB_create_context; 145 | GLFWbool ARB_create_context_profile; 146 | GLFWbool EXT_create_context_es2_profile; 147 | GLFWbool ARB_create_context_robustness; 148 | GLFWbool ARB_create_context_no_error; 149 | GLFWbool ARB_context_flush_control; 150 | 151 | } _GLFWlibraryWGL; 152 | 153 | 154 | GLFWbool _glfwInitWGL(void); 155 | void _glfwTerminateWGL(void); 156 | GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, 157 | const _GLFWctxconfig* ctxconfig, 158 | const _GLFWfbconfig* fbconfig); 159 | 160 | -------------------------------------------------------------------------------- /extern/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | 52 | void _glfwInitJoysticksWin32(void); 53 | void _glfwTerminateJoysticksWin32(void); 54 | void _glfwDetectJoystickConnectionWin32(void); 55 | void _glfwDetectJoystickDisconnectionWin32(void); 56 | 57 | -------------------------------------------------------------------------------- /extern/glfw/src/win32_thread.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW platform API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls) 38 | { 39 | assert(tls->win32.allocated == GLFW_FALSE); 40 | 41 | tls->win32.index = TlsAlloc(); 42 | if (tls->win32.index == TLS_OUT_OF_INDEXES) 43 | { 44 | _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, 45 | "Win32: Failed to allocate TLS index"); 46 | return GLFW_FALSE; 47 | } 48 | 49 | tls->win32.allocated = GLFW_TRUE; 50 | return GLFW_TRUE; 51 | } 52 | 53 | void _glfwPlatformDestroyTls(_GLFWtls* tls) 54 | { 55 | if (tls->win32.allocated) 56 | TlsFree(tls->win32.index); 57 | memset(tls, 0, sizeof(_GLFWtls)); 58 | } 59 | 60 | void* _glfwPlatformGetTls(_GLFWtls* tls) 61 | { 62 | assert(tls->win32.allocated == GLFW_TRUE); 63 | return TlsGetValue(tls->win32.index); 64 | } 65 | 66 | void _glfwPlatformSetTls(_GLFWtls* tls, void* value) 67 | { 68 | assert(tls->win32.allocated == GLFW_TRUE); 69 | TlsSetValue(tls->win32.index, value); 70 | } 71 | 72 | GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex) 73 | { 74 | assert(mutex->win32.allocated == GLFW_FALSE); 75 | InitializeCriticalSection(&mutex->win32.section); 76 | return mutex->win32.allocated = GLFW_TRUE; 77 | } 78 | 79 | void _glfwPlatformDestroyMutex(_GLFWmutex* mutex) 80 | { 81 | if (mutex->win32.allocated) 82 | DeleteCriticalSection(&mutex->win32.section); 83 | memset(mutex, 0, sizeof(_GLFWmutex)); 84 | } 85 | 86 | void _glfwPlatformLockMutex(_GLFWmutex* mutex) 87 | { 88 | assert(mutex->win32.allocated == GLFW_TRUE); 89 | EnterCriticalSection(&mutex->win32.section); 90 | } 91 | 92 | void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) 93 | { 94 | assert(mutex->win32.allocated == GLFW_TRUE); 95 | LeaveCriticalSection(&mutex->win32.section); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /extern/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Initialise timer 36 | // 37 | void _glfwInitTimerWin32(void) 38 | { 39 | uint64_t frequency; 40 | 41 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 42 | { 43 | _glfw.timer.win32.hasPC = GLFW_TRUE; 44 | _glfw.timer.win32.frequency = frequency; 45 | } 46 | else 47 | { 48 | _glfw.timer.win32.hasPC = GLFW_FALSE; 49 | _glfw.timer.win32.frequency = 1000; 50 | } 51 | } 52 | 53 | 54 | ////////////////////////////////////////////////////////////////////////// 55 | ////// GLFW platform API ////// 56 | ////////////////////////////////////////////////////////////////////////// 57 | 58 | uint64_t _glfwPlatformGetTimerValue(void) 59 | { 60 | if (_glfw.timer.win32.hasPC) 61 | { 62 | uint64_t value; 63 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 64 | return value; 65 | } 66 | else 67 | return (uint64_t) timeGetTime(); 68 | } 69 | 70 | uint64_t _glfwPlatformGetTimerFrequency(void) 71 | { 72 | return _glfw.timer.win32.frequency; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /extern/glfw/src/wl_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Wayland - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | static void outputHandleGeometry(void* data, 36 | struct wl_output* output, 37 | int32_t x, 38 | int32_t y, 39 | int32_t physicalWidth, 40 | int32_t physicalHeight, 41 | int32_t subpixel, 42 | const char* make, 43 | const char* model, 44 | int32_t transform) 45 | { 46 | struct _GLFWmonitor *monitor = data; 47 | char name[1024]; 48 | 49 | monitor->wl.x = x; 50 | monitor->wl.y = y; 51 | monitor->widthMM = physicalWidth; 52 | monitor->heightMM = physicalHeight; 53 | 54 | snprintf(name, sizeof(name), "%s %s", make, model); 55 | monitor->name = _glfw_strdup(name); 56 | } 57 | 58 | static void outputHandleMode(void* data, 59 | struct wl_output* output, 60 | uint32_t flags, 61 | int32_t width, 62 | int32_t height, 63 | int32_t refresh) 64 | { 65 | struct _GLFWmonitor *monitor = data; 66 | GLFWvidmode mode; 67 | 68 | mode.width = width; 69 | mode.height = height; 70 | mode.redBits = 8; 71 | mode.greenBits = 8; 72 | mode.blueBits = 8; 73 | mode.refreshRate = refresh / 1000; 74 | 75 | monitor->modeCount++; 76 | monitor->modes = 77 | realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode)); 78 | monitor->modes[monitor->modeCount - 1] = mode; 79 | 80 | if (flags & WL_OUTPUT_MODE_CURRENT) 81 | monitor->wl.currentMode = monitor->modeCount - 1; 82 | } 83 | 84 | static void outputHandleDone(void* data, struct wl_output* output) 85 | { 86 | struct _GLFWmonitor *monitor = data; 87 | 88 | _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); 89 | } 90 | 91 | static void outputHandleScale(void* data, 92 | struct wl_output* output, 93 | int32_t factor) 94 | { 95 | struct _GLFWmonitor *monitor = data; 96 | 97 | monitor->wl.scale = factor; 98 | } 99 | 100 | static const struct wl_output_listener outputListener = { 101 | outputHandleGeometry, 102 | outputHandleMode, 103 | outputHandleDone, 104 | outputHandleScale, 105 | }; 106 | 107 | 108 | ////////////////////////////////////////////////////////////////////////// 109 | ////// GLFW internal API ////// 110 | ////////////////////////////////////////////////////////////////////////// 111 | 112 | void _glfwAddOutputWayland(uint32_t name, uint32_t version) 113 | { 114 | _GLFWmonitor *monitor; 115 | struct wl_output *output; 116 | 117 | if (version < 2) 118 | { 119 | _glfwInputError(GLFW_PLATFORM_ERROR, 120 | "Wayland: Unsupported output interface version"); 121 | return; 122 | } 123 | 124 | // The actual name of this output will be set in the geometry handler. 125 | monitor = _glfwAllocMonitor(NULL, 0, 0); 126 | 127 | output = wl_registry_bind(_glfw.wl.registry, 128 | name, 129 | &wl_output_interface, 130 | 2); 131 | if (!output) 132 | { 133 | _glfwFreeMonitor(monitor); 134 | return; 135 | } 136 | 137 | monitor->wl.scale = 1; 138 | monitor->wl.output = output; 139 | monitor->wl.name = name; 140 | 141 | wl_output_add_listener(output, &outputListener, monitor); 142 | } 143 | 144 | 145 | ////////////////////////////////////////////////////////////////////////// 146 | ////// GLFW platform API ////// 147 | ////////////////////////////////////////////////////////////////////////// 148 | 149 | void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) 150 | { 151 | if (monitor->wl.output) 152 | wl_output_destroy(monitor->wl.output); 153 | } 154 | 155 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 156 | { 157 | if (xpos) 158 | *xpos = monitor->wl.x; 159 | if (ypos) 160 | *ypos = monitor->wl.y; 161 | } 162 | 163 | void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, 164 | float* xscale, float* yscale) 165 | { 166 | if (xscale) 167 | *xscale = (float) monitor->wl.scale; 168 | if (yscale) 169 | *yscale = (float) monitor->wl.scale; 170 | } 171 | 172 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 173 | { 174 | *found = monitor->modeCount; 175 | return monitor->modes; 176 | } 177 | 178 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 179 | { 180 | *mode = monitor->modes[monitor->wl.currentMode]; 181 | } 182 | 183 | GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 184 | { 185 | _glfwInputError(GLFW_PLATFORM_ERROR, 186 | "Wayland: Gamma ramp access it not available"); 187 | return GLFW_FALSE; 188 | } 189 | 190 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, 191 | const GLFWgammaramp* ramp) 192 | { 193 | _glfwInputError(GLFW_PLATFORM_ERROR, 194 | "Wayland: Gamma ramp access is not available"); 195 | } 196 | 197 | 198 | ////////////////////////////////////////////////////////////////////////// 199 | ////// GLFW native API ////// 200 | ////////////////////////////////////////////////////////////////////////// 201 | 202 | GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) 203 | { 204 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 205 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 206 | return monitor->wl.output; 207 | } 208 | 209 | -------------------------------------------------------------------------------- /extern/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /extern/imgui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(imgui CXX) 2 | 3 | # dear imgui 4 | set(IMGUI_SOURCE_FILES 5 | imgui.cpp 6 | imgui_demo.cpp 7 | imgui_draw.cpp 8 | imgui_widgets.cpp) 9 | 10 | set(IMGUI_HEADER_FILES 11 | imconfig.h 12 | imgui.h 13 | imgui_internal.h 14 | imstb_rectpack.h 15 | imstb_textedit.h 16 | imstb_truetype.h) 17 | 18 | add_library(imgui STATIC ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES}) 19 | target_include_directories(imgui PUBLIC ..) 20 | -------------------------------------------------------------------------------- /extern/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h) 7 | // B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h" 8 | // If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include 9 | // the imgui*.cpp files but also _any_ of your code that uses imgui. This is because some compile-time options have an affect on data structures. 10 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 11 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 12 | //----------------------------------------------------------------------------- 13 | 14 | #pragma once 15 | 16 | //---- Define assertion handler. Defaults to calling assert(). 17 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 18 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 19 | 20 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 21 | //#define IMGUI_API __declspec( dllexport ) 22 | //#define IMGUI_API __declspec( dllimport ) 23 | 24 | //---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 25 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 26 | 27 | //---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty) 28 | //---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp. 29 | //#define IMGUI_DISABLE_DEMO_WINDOWS 30 | 31 | //---- Don't implement some functions to reduce linkage requirements. 32 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. 33 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. 34 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function. 35 | //#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf. 36 | //#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h. 37 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 38 | 39 | //---- Include imgui_user.h at the end of imgui.h as a convenience 40 | //#define IMGUI_INCLUDE_IMGUI_USER_H 41 | 42 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 43 | //#define IMGUI_USE_BGRA_PACKED_COLOR 44 | 45 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 46 | // By default the embedded implementations are declared static and not available outside of imgui cpp files. 47 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 48 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 49 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 50 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 51 | 52 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 53 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 54 | /* 55 | #define IM_VEC2_CLASS_EXTRA \ 56 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 57 | operator MyVec2() const { return MyVec2(x,y); } 58 | 59 | #define IM_VEC4_CLASS_EXTRA \ 60 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 61 | operator MyVec4() const { return MyVec4(x,y,z,w); } 62 | */ 63 | 64 | //---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it. 65 | //#define ImDrawIdx unsigned int 66 | 67 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 68 | /* 69 | namespace ImGui 70 | { 71 | void MyFunction(const char* name, const MyMatrix44& v); 72 | } 73 | */ 74 | -------------------------------------------------------------------------------- /extern/sajson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(sajson CXX) 2 | 3 | add_library(sajson INTERFACE) 4 | # target_sources(sajson INTERFACE sajson.h) 5 | target_include_directories(sajson INTERFACE ..) 6 | -------------------------------------------------------------------------------- /include/dynamic-tree/tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "dynamic-tree/utils.h" 15 | #include 16 | 17 | #define dt_nullNode (-1) 18 | 19 | enum dtInsertionHeuristic 20 | { 21 | dt_sah = 0, 22 | dt_sah_rotate, 23 | dt_bittner, 24 | dt_approx_sah, 25 | dt_approx_sah_rotate, 26 | dt_manhattan 27 | }; 28 | 29 | /// A node in the dynamic tree. The client does not interact with this directly. 30 | struct dtNode 31 | { 32 | /// Enlarged AABB 33 | dtAABB aabb; 34 | 35 | union 36 | { 37 | int parent; 38 | int next; 39 | }; 40 | 41 | int child1; 42 | int child2; 43 | 44 | // leaf = 0, free node = dt_nullNode 45 | int height; 46 | 47 | int objectIndex; 48 | 49 | bool isLeaf; 50 | }; 51 | 52 | struct dtCandidateNode 53 | { 54 | int index; 55 | float inheritanceCost; 56 | }; 57 | 58 | struct dtCost 59 | { 60 | int node; 61 | float cost; 62 | }; 63 | 64 | /// A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. 65 | /// A dynamic tree arranges data in a binary tree to accelerate 66 | /// queries such as volume queries and ray casts. Leafs are proxies 67 | /// with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor 68 | /// so that the proxy AABB is bigger than the client object. This allows the client 69 | /// object to move by small amounts without triggering a tree update. 70 | /// 71 | /// Nodes are pooled and relocatable, so we use node indices rather than pointers. 72 | struct dtTree 73 | { 74 | /// Constructing the tree initializes the node pool. 75 | dtTree(); 76 | 77 | /// Destroy the tree, freeing the node pool. 78 | ~dtTree(); 79 | 80 | void Clear(); 81 | 82 | /// Create a proxy. Provide a tight fitting AABB and a userData pointer. 83 | int CreateProxy(const dtAABB& aabb, int objectIndex); 84 | 85 | /// Destroy a proxy. This asserts if the id is invalid. 86 | void DestroyProxy(int proxyId); 87 | 88 | /// Get the fat AABB for a proxy. 89 | const dtAABB& GetAABB(int proxyId) const; 90 | 91 | /// Validate this tree. For testing. 92 | void Validate() const; 93 | 94 | /// Get the proxy/leaf count 95 | int GetProxyCount() const; 96 | 97 | /// Get the cached height. 98 | int GetHeight() const; 99 | 100 | /// Get the maximum balance of an node in the tree. The balance is the difference 101 | /// in height of the two children of a node. 102 | int GetMaxBalance() const; 103 | 104 | /// Get the ratio of the sum of the internal node areas to the root area. 105 | float GetAreaRatio() const; 106 | 107 | /// Get the area of the internal nodes 108 | float GetArea() const; 109 | 110 | /// Build an optimal tree. Very expensive. For testing. 111 | void RebuildBottomUp(); 112 | 113 | /// Build top down using SAH 114 | void BuildTopDownSAH(int* proxies, dtAABB* aabbs, int count); 115 | int BinSortBoxes(int parentIndex, dtNode* leaves, int count, struct dtTreeBin* bins, struct dtTreePlane* planes); 116 | 117 | /// Build top down using the median split 118 | void BuildTopDownMedianSplit(int* proxies, dtAABB* aabbs, int count); 119 | int PartitionBoxes(int parentIndex, dtNode* leaves, int count); 120 | 121 | void WriteDot(const char* fileName) const; 122 | 123 | int AllocateNode(); 124 | void FreeNode(int node); 125 | 126 | void InsertLeaf(int leaf); 127 | void InsertLeafSAH(int leaf); 128 | void InsertLeafBittner(int leaf); 129 | void InsertLeafApproxSAH(int leaf); 130 | void InsertLeafManhattan(int leaf); 131 | void RemoveLeaf(int leaf); 132 | 133 | dtCost MinCost(int index, const dtAABB& box); 134 | 135 | float SiblingCost(const dtAABB& aabbL, int sibling); 136 | int SiblingApproxSAH(const dtAABB& aabbL); 137 | //int SiblingApproxSAH2(const dtAABB& aabbL); 138 | int SiblingApproxOmohundro(const dtAABB& aabbL, std::vector& path, float& cost); 139 | void Rotate(int index); 140 | 141 | void Optimize(int iterations); 142 | void Shuffle(int index); 143 | 144 | int ComputeHeight() const; 145 | int ComputeHeight(int nodeId) const; 146 | 147 | void ValidateStructure(int index) const; 148 | void ValidateMetrics(int index) const; 149 | 150 | int m_root; 151 | 152 | dtNode* m_nodes; 153 | int m_nodeCount; 154 | int m_nodeCapacity; 155 | int m_proxyCount; 156 | 157 | int m_freeList; 158 | 159 | int m_countBF; 160 | int m_countBG; 161 | int m_countCD; 162 | int m_countCE; 163 | 164 | /// This is used to incrementally traverse the tree for re-balancing. 165 | int m_path; 166 | 167 | int m_insertionCount; 168 | 169 | dtInsertionHeuristic m_heuristic; 170 | 171 | std::vector m_heap; 172 | int m_maxHeapCount; 173 | }; 174 | -------------------------------------------------------------------------------- /launch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This builds the project files and launches Visual Studio 4 | mkdir build 5 | cd build 6 | cmake -G "Visual Studio 16 2019" .. 7 | start dynamic-tree.sln 8 | -------------------------------------------------------------------------------- /math.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | [{m128_f32[0]}, {m128_f32[1]}, {m128_f32[2]}, {m128_f32[3]}] 6 | 7 | m128_f32[0] 8 | m128_f32[1] 9 | m128_f32[2] 10 | m128_f32[3] 11 | (void*)this 12 | 13 | 14 | 15 | 16 | [{m256_f32[0]}, {m256_f32[1]}, {m256_f32[2]}, {m256_f32[3]}, {m256_f32[4]}, {m256_f32[5]}, {m256_f32[6]}, {m256_f32[7]}] 17 | 18 | m256_f32[0] 19 | m256_f32[1] 20 | m256_f32[2] 21 | m256_f32[3] 22 | m256_f32[4] 23 | m256_f32[5] 24 | m256_f32[6] 25 | m256_f32[7] 26 | (void*)this 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(samples LANGUAGES CXX) 2 | 3 | set (SAMPLE_SOURCE_FILES 4 | glad.c 5 | imgui_impl_glfw.cpp 6 | imgui_impl_opengl3.cpp 7 | draw.cpp 8 | main.cpp 9 | settings.cpp 10 | test.cpp 11 | test1.cpp 12 | test2.cpp 13 | test3.cpp 14 | test4.cpp) 15 | 16 | set (SAMPLE_HEADER_FILES 17 | khrplatform.h 18 | glad.h 19 | imgui_impl_glfw.h 20 | imgui_impl_opengl3.h 21 | draw.h 22 | settings.h 23 | test.h) 24 | 25 | add_executable(samples ${SAMPLE_SOURCE_FILES} ${SAMPLE_HEADER_FILES}) 26 | target_include_directories(samples PUBLIC ${OPENGL_INCLUDE_DIR}) 27 | target_link_libraries(samples PUBLIC dynamic-tree glfw imgui sajson ${OPENGL_LIBRARIES}) 28 | -------------------------------------------------------------------------------- /samples/data/BlizzardLandKinematic.txt: -------------------------------------------------------------------------------- 1 | v -19.2352 8.80877 118.46 2 | v -18.8547 9.57551 119.449 3 | v -19.761 8.80877 118.46 4 | v -19.3804 9.57551 119.449 5 | v -19.1989 9.31588 118.611 6 | v -18.8883 10.1649 119.569 7 | v -19.5214 9.4245 118.987 8 | v -19.0943 10.291 119.899 9 | v -19.7273 9.31588 118.611 10 | v -19.4168 10.1649 119.569 11 | v -20.0154 8.63631 118.297 12 | v -18.6156 10.0441 120.072 13 | v -19.4171 9.13085 119.4 14 | v -19.1971 9.35085 119.62 15 | v -19.2352 8.80877 118.46 16 | v -18.8547 9.57551 119.449 17 | v -19.761 8.80877 118.46 18 | v -19.3804 9.57551 119.449 19 | v -19.1989 9.31588 118.611 20 | v -18.8883 10.1649 119.569 21 | v -19.5214 9.4245 118.987 22 | v -19.0943 10.291 119.899 23 | v -19.7273 9.31588 118.611 24 | v -19.4168 10.1649 119.569 25 | v -20.0154 8.63631 118.297 26 | v -18.6156 10.0441 120.072 27 | v -19.4171 9.13085 119.4 28 | v -19.1971 9.35085 119.62 29 | v -19.2352 8.80877 118.46 30 | v -18.8547 9.57551 119.449 31 | v -19.761 8.80877 118.46 32 | v -19.3804 9.57551 119.449 33 | v -19.1989 9.31588 118.611 34 | v -18.8883 10.1649 119.569 35 | v -19.5214 9.4245 118.987 36 | v -19.0943 10.291 119.899 37 | v -19.7273 9.31588 118.611 38 | v -19.4168 10.1649 119.569 39 | v -20.0154 8.63631 118.297 40 | v -18.6156 10.0441 120.072 41 | v -19.4171 9.13085 119.4 42 | v -19.1971 9.35085 119.62 43 | v -19.2352 8.80877 118.46 44 | v -18.8547 9.57551 119.449 45 | v -19.761 8.80877 118.46 46 | v -19.3804 9.57551 119.449 47 | v -19.1989 9.31588 118.611 48 | v -18.8883 10.1649 119.569 49 | v -19.5214 9.4245 118.987 50 | v -19.0943 10.291 119.899 51 | v -19.7273 9.31588 118.611 52 | v -19.4168 10.1649 119.569 53 | v -20.0154 8.63631 118.297 54 | v -18.6156 10.0441 120.072 55 | v -19.4171 9.13085 119.4 56 | v -19.1971 9.35085 119.62 57 | v -19.2352 8.80877 118.46 58 | v -18.8547 9.57551 119.449 59 | v -19.761 8.80877 118.46 60 | v -19.3804 9.57551 119.449 61 | v -19.1989 9.31588 118.611 62 | v -18.8883 10.1649 119.569 63 | v -19.5214 9.4245 118.987 64 | v -19.0943 10.291 119.899 65 | v -19.7273 9.31588 118.611 66 | v -19.4168 10.1649 119.569 67 | v -20.0154 8.63631 118.297 68 | v -18.6156 10.0441 120.072 69 | v -19.4171 9.13085 119.4 70 | v -19.1971 9.35085 119.62 71 | v -36.8007 8.00859 118.621 72 | v -36.062 8.76625 119.446 73 | v -36.3235 8.0671 118.972 74 | v -35.6405 8.80577 119.848 75 | v -36.6607 8.47545 118.527 76 | v -35.9635 9.35682 119.265 77 | v -36.2701 8.57371 118.356 78 | v -35.5105 9.47372 119.13 79 | v -36.3215 8.51681 118.831 80 | v -35.5839 9.39738 119.547 81 | v -36.7197 7.78815 118.199 82 | v -35.2753 9.20863 119.747 83 | v -35.9606 8.29729 118.672 84 | v -35.7406 8.51729 118.892 85 | v -33.4949 4.52539 122.908 86 | v -32.8134 5.25015 123.796 87 | v -32.949 4.45193 123.174 88 | v -32.3228 5.20088 124.101 89 | v -33.1681 4.94465 122.813 90 | v -32.6892 5.84177 123.67 91 | v -32.8149 4.98021 122.597 92 | v -32.2246 5.89624 123.456 93 | v -32.7832 4.89274 123.043 94 | v -32.2464 5.79084 123.884 95 | v -33.2678 4.20151 122.396 96 | v -31.9691 5.61996 124.099 97 | v -32.7236 4.7127 122.893 98 | v -32.5036 4.9327 123.113 99 | v -18.9822 10.4587 105.885 100 | v -17.957 11.1879 106.31 101 | v -19.0994 10.4587 105.29 102 | v -18.0934 11.1879 105.785 103 | v -19.138 10.8647 105.898 104 | v -18.2755 11.7837 106.328 105 | v -19.545 10.9184 105.725 106 | v -18.6901 11.848 106.21 107 | v -19.2396 10.8647 105.444 108 | v -18.3701 11.7837 105.81 109 | v -19.6962 10.1599 105.243 110 | v -17.9265 11.5578 106.603 111 | v -19.198 10.6499 105.825 112 | v -18.978 10.8699 106.045 113 | v -26.3331 8.44134 120.058 114 | v -25.946 9.20808 121.049 115 | v -25.8016 8.44134 120.022 116 | v -25.3909 9.20808 121.007 117 | v -26.3118 8.94845 119.936 118 | v -25.9604 9.79748 120.891 119 | v -26.1286 9.05707 119.59 120 | v -25.6879 9.92354 120.502 121 | v -25.7712 8.94845 119.904 122 | v -25.4654 9.79748 120.862 123 | v -26.5885 8.26887 119.411 124 | v -25.1947 9.67663 121.194 125 | v -26.0123 8.76342 119.87 126 | v -25.7923 8.98342 120.09 127 | v -19.4171 9.13085 119.4 128 | v -19.1971 9.35085 119.62 129 | v -20.0154 8.63631 118.297 130 | v -18.6156 10.0441 120.072 131 | v -19.7273 9.31588 118.611 132 | v -19.4168 10.1649 119.569 133 | v -19.5214 9.4245 118.987 134 | v -19.0943 10.291 119.899 135 | v -19.1989 9.31588 118.611 136 | v -18.8883 10.1649 119.569 137 | v -19.761 8.80877 118.46 138 | v -19.3804 9.57551 119.449 139 | v -19.2352 8.80877 118.46 140 | v -18.8547 9.57551 119.449 141 | -------------------------------------------------------------------------------- /samples/data/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erincatto/dynamic-tree/ef5fa625677969897c22bda20af447ac1abc8ca1/samples/data/DroidSans.ttf -------------------------------------------------------------------------------- /samples/dot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | dot -Tsvg dot.txt > dot.svg 4 | start dot.svg 5 | -------------------------------------------------------------------------------- /samples/dot.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 0 14 | 15 | A 16 | 17 | 18 | 19 | 1 20 | 21 | B 22 | 23 | 24 | 25 | 2 26 | 27 | 28 | 29 | 30 | 3 31 | 32 | C 33 | 34 | 35 | 36 | 2--3 37 | 38 | 39 | 40 | 41 | 4 42 | 43 | 44 | 45 | 46 | 2--4 47 | 48 | 49 | 50 | 51 | 4--0 52 | 53 | 54 | 55 | 56 | 4--1 57 | 58 | 59 | 60 | 61 | 16 62 | 63 | area ratio = 0.28 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /samples/dot.txt: -------------------------------------------------------------------------------- 1 | graph 2 | { 3 | 0 [shape=box, width=0.25, height=0.25, label="A"] 4 | 1 [shape=box, width=0.25, height=0.25, label="B"] 5 | 2 [shape=circle, width=0.25, height=0.25, label=""] 6 | 3 [shape=box, width=0.25, height=0.25, label="C"] 7 | 4 [shape=circle, width=0.25, height=0.25, label=""] 8 | 2 -- 4 9 | 2 -- 3 10 | 4 -- 0 11 | 4 -- 1 12 | 16 [shape=box, fontsize=10, label="area ratio = 0.28"] 13 | } 14 | -------------------------------------------------------------------------------- /samples/draw.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erincatto/dynamic-tree/ef5fa625677969897c22bda20af447ac1abc8ca1/samples/draw.cpp -------------------------------------------------------------------------------- /samples/draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "dynamic-tree/utils.h" 15 | 16 | struct Camera 17 | { 18 | Camera(); 19 | 20 | void Resize(int width, int height); 21 | void Reset(); 22 | 23 | const dtVec GetUp() const; 24 | const dtVec GetRight() const; 25 | const dtVec GetForward() const; 26 | 27 | // Update position and rotation 28 | void Update(); 29 | 30 | dtMtx GetCameraMatrix() const; 31 | dtMtx GetViewMatrix() const; 32 | dtMtx GetPerspectiveMatrix() const; 33 | 34 | void ConvertScreenToWorldRay(dtVec& p1, dtVec& p2, float xs, float ys) const; 35 | bool ConvertWorldToScreen(float& xs, float& ys, dtVec p) const; 36 | 37 | dtMtx m_matrix; 38 | 39 | // Vertical field of view 40 | float m_fovy; 41 | float m_tany; 42 | 43 | float m_yaw; // [0, 2pi] 44 | float m_pitch; // [0, pi] 45 | 46 | float m_near; 47 | float m_far; 48 | 49 | // Screen width and height 50 | int m_ws; 51 | int m_hs; 52 | 53 | float m_ratio; 54 | 55 | // Near plane width and height 56 | float m_wc; 57 | float m_hc; 58 | 59 | // Far plane width and height 60 | float m_wf; 61 | float m_hf; 62 | }; 63 | 64 | struct Color 65 | { 66 | Color() {} 67 | Color(float red, float green, float blue) 68 | : r(red), g(green), b(blue), a(1.0f) {} 69 | Color(float red, float green, float blue, float alpha) 70 | : r(red), g(green), b(blue), a(alpha) {} 71 | 72 | void Set(float red, float green, float blue) 73 | { 74 | r = red; 75 | g = green; 76 | b = blue; 77 | a = 1.0f; 78 | } 79 | void Set(float red, float green, float blue, float alpha) 80 | { 81 | r = red; 82 | g = green; 83 | b = blue; 84 | a = alpha; 85 | } 86 | float r, g, b, a; 87 | }; 88 | 89 | struct Draw 90 | { 91 | Draw(); 92 | ~Draw(); 93 | 94 | void Create(); 95 | void Destroy(); 96 | 97 | void DrawBox(const dtAABB&, float extension, const Color& color); 98 | 99 | void DrawSegment(dtVec point1, dtVec point2, const Color& color); 100 | 101 | void DrawPoint(dtVec point, float size, const Color& color); 102 | 103 | void DrawAxes(); 104 | 105 | void DrawString(float x, float y, const char* sz, ...); 106 | 107 | void DrawString(dtVec p, const Color& color, const char* sz, ...); 108 | 109 | void Flush(); 110 | 111 | Camera m_camera; 112 | struct GLDynamicPoints* m_points; 113 | struct GLDynamicLines* m_lines; 114 | float m_uiScale; 115 | bool m_showUI; 116 | }; 117 | -------------------------------------------------------------------------------- /samples/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. 9 | // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 12 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 13 | // https://github.com/ocornut/imgui 14 | 15 | // About GLSL version: 16 | // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. 17 | // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! 18 | 19 | #pragma once 20 | 21 | struct GLFWwindow; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 24 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 25 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 27 | 28 | // InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any. 29 | // InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks. 30 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 31 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 32 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 33 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 34 | -------------------------------------------------------------------------------- /samples/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) 2 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 3 | // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) 4 | 5 | // Implemented features: 6 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 9 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 10 | // https://github.com/ocornut/imgui 11 | 12 | // About OpenGL function loaders: 13 | // About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually. 14 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad. 15 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 16 | 17 | // About GLSL version: 18 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 19 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 20 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 21 | 22 | #pragma once 23 | 24 | // MOD_ERIN 25 | #define IMGUI_IMPL_OPENGL_LOADER_GLAD 26 | 27 | // Set default OpenGL loader to be gl3w 28 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 29 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 30 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 31 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 32 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W 33 | #endif 34 | 35 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 36 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 37 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 38 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 39 | 40 | // Called by Init/NewFrame/Shutdown 41 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 42 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 43 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 44 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 45 | -------------------------------------------------------------------------------- /samples/settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #define _CRT_SECURE_NO_WARNINGS 13 | #include "settings.h" 14 | #include "sajson/sajson.h" 15 | #include 16 | 17 | static const char* fileName = "settings.ini"; 18 | static const char* testIndexKey = "testIndex"; 19 | 20 | // Load a file. You must free the character array. 21 | static bool sReadFile(char*& data, int& size, const char* filename) 22 | { 23 | FILE* file = fopen(filename, "rb"); 24 | if (file == nullptr) 25 | { 26 | return false; 27 | } 28 | 29 | fseek(file, 0, SEEK_END); 30 | size = ftell(file); 31 | fseek(file, 0, SEEK_SET); 32 | 33 | if (size == 0) 34 | { 35 | return false; 36 | } 37 | 38 | data = (char*)malloc(size + 1); 39 | fread(data, size, 1, file); 40 | fclose(file); 41 | data[size] = 0; 42 | 43 | return true; 44 | } 45 | 46 | void Settings::Save() 47 | { 48 | FILE* file = fopen(fileName, "w"); 49 | fprintf(file, "{\n"); 50 | fprintf(file, " \"%s\": %d\n", testIndexKey, m_testIndex); 51 | fprintf(file, "}\n"); 52 | fclose(file); 53 | } 54 | 55 | void Settings::Load() 56 | { 57 | char* data = nullptr; 58 | int size = 0; 59 | bool found = sReadFile(data, size, fileName); 60 | if (found == false) 61 | { 62 | return; 63 | } 64 | 65 | const sajson::document& document = sajson::parse(sajson::dynamic_allocation(), sajson::mutable_string_view(size, data)); 66 | 67 | sajson::value root = document.get_root(); 68 | 69 | if (root.get_type() == sajson::TYPE_OBJECT) 70 | { 71 | size_t index = root.find_object_key(sajson::string(testIndexKey, strlen(testIndexKey))); 72 | if (index < root.get_length()) 73 | { 74 | sajson::value testIndex = root.get_object_value(index); 75 | if (testIndex.get_type() == sajson::TYPE_INTEGER) 76 | { 77 | m_testIndex = testIndex.get_integer_value(); 78 | } 79 | } 80 | } 81 | 82 | free(data); 83 | } 84 | -------------------------------------------------------------------------------- /samples/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #pragma once 13 | 14 | struct Settings 15 | { 16 | Settings() 17 | { 18 | m_testIndex = 0; 19 | } 20 | 21 | void Save(); 22 | void Load(); 23 | 24 | int m_testIndex; 25 | }; 26 | -------------------------------------------------------------------------------- /samples/sort_balanced.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | %3 11 | 12 | 13 | 0 14 | 15 | A 16 | 17 | 18 | 1 19 | 20 | B 21 | 22 | 23 | 2 24 | 25 | 26 | 27 | 6 28 | 29 | 30 | 31 | 2--6 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 39 | 2--10 40 | 41 | 42 | 43 | 3 44 | 45 | C 46 | 47 | 48 | 4 49 | 50 | 51 | 52 | 4--0 53 | 54 | 55 | 56 | 4--1 57 | 58 | 59 | 60 | 5 61 | 62 | D 63 | 64 | 65 | 6--4 66 | 67 | 68 | 69 | 8 70 | 71 | 72 | 73 | 6--8 74 | 75 | 76 | 77 | 7 78 | 79 | E 80 | 81 | 82 | 8--3 83 | 84 | 85 | 86 | 8--5 87 | 88 | 89 | 90 | 9 91 | 92 | F 93 | 94 | 95 | 12 96 | 97 | 98 | 99 | 10--12 100 | 101 | 102 | 103 | 14 104 | 105 | 106 | 107 | 10--14 108 | 109 | 110 | 111 | 11 112 | 113 | G 114 | 115 | 116 | 12--7 117 | 118 | 119 | 120 | 12--9 121 | 122 | 123 | 124 | 13 125 | 126 | H 127 | 128 | 129 | 14--11 130 | 131 | 132 | 133 | 14--13 134 | 135 | 136 | 137 | 16 138 | 139 | area ratio = 2.24 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /samples/sort_linked.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | %3 11 | 12 | 13 | 0 14 | 15 | A 16 | 17 | 18 | 1 19 | 20 | B 21 | 22 | 23 | 2 24 | 25 | 26 | 27 | 2--0 28 | 29 | 30 | 31 | 4 32 | 33 | 34 | 35 | 2--4 36 | 37 | 38 | 39 | 3 40 | 41 | C 42 | 43 | 44 | 4--1 45 | 46 | 47 | 48 | 6 49 | 50 | 51 | 52 | 4--6 53 | 54 | 55 | 56 | 5 57 | 58 | D 59 | 60 | 61 | 6--3 62 | 63 | 64 | 65 | 8 66 | 67 | 68 | 69 | 6--8 70 | 71 | 72 | 73 | 7 74 | 75 | E 76 | 77 | 78 | 8--5 79 | 80 | 81 | 82 | 10 83 | 84 | 85 | 86 | 8--10 87 | 88 | 89 | 90 | 9 91 | 92 | F 93 | 94 | 95 | 10--7 96 | 97 | 98 | 99 | 12 100 | 101 | 102 | 103 | 10--12 104 | 105 | 106 | 107 | 11 108 | 109 | G 110 | 111 | 112 | 12--9 113 | 114 | 115 | 116 | 14 117 | 118 | 119 | 120 | 12--14 121 | 122 | 123 | 124 | 13 125 | 126 | H 127 | 128 | 129 | 14--11 130 | 131 | 132 | 133 | 14--13 134 | 135 | 136 | 137 | 16 138 | 139 | area ratio = 3.53 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /samples/test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #define _CRT_SECURE_NO_WARNINGS 13 | #include "test.h" 14 | #include "draw.h" 15 | 16 | #include 17 | #include 18 | 19 | void Test::Create(dtInsertionHeuristic heuristic) 20 | { 21 | CreateBoxes(); 22 | 23 | m_tree.m_heuristic = heuristic; 24 | 25 | dtTimer timer; 26 | for (int i = 0; i < m_count; ++i) 27 | { 28 | m_proxies[i] = m_tree.CreateProxy(m_boxes[i], i); 29 | } 30 | m_buildTime = timer.GetMilliseconds(); 31 | 32 | m_proxyCount = 0; 33 | m_nodeCount = 0; 34 | m_treeHeight = 0; 35 | m_heapCount = 0; 36 | m_treeArea = 0.0f; 37 | 38 | m_proxyCount = m_tree.GetProxyCount(); 39 | m_nodeCount = m_tree.m_nodeCount; 40 | m_treeHeight = m_tree.GetHeight(); 41 | m_heapCount = m_tree.m_maxHeapCount; 42 | m_treeArea = m_tree.GetAreaRatio(); 43 | 44 | m_base = 0; 45 | } 46 | 47 | void Test::Update(Draw& draw, int reinsertIter, int shuffleIter) 48 | { 49 | if (m_count == 0) 50 | { 51 | return; 52 | } 53 | 54 | dtTimer timer; 55 | for (int i = 0; i < reinsertIter; ++i) 56 | { 57 | int index = m_base; 58 | m_tree.DestroyProxy(m_proxies[index]); 59 | 60 | m_proxies[index] = m_tree.CreateProxy(m_boxes[index], i); 61 | 62 | m_base += 1; 63 | if (m_base == m_count) 64 | { 65 | m_base = 0; 66 | } 67 | } 68 | 69 | m_tree.Optimize(shuffleIter); 70 | 71 | float updateTime = timer.GetMilliseconds(); 72 | 73 | draw.DrawString(5, 50, "build time = %6.2f, update time = %8.2f us", m_buildTime, 1000.0f * updateTime); 74 | 75 | int height = m_tree.GetHeight(); 76 | float area = m_tree.GetAreaRatio(); 77 | draw.DrawString(5, 65, "current height = %d, area = %g", height, area); 78 | } 79 | 80 | void Test::Destroy() 81 | { 82 | m_tree.Clear(); 83 | free(m_boxes); 84 | free(m_proxies); 85 | m_boxes = nullptr; 86 | m_proxies = nullptr; 87 | m_count = 0; 88 | } 89 | 90 | void Test::Allocate(int count) 91 | { 92 | m_boxes = (dtAABB*)malloc(count * sizeof(dtAABB)); 93 | m_proxies = (int*)malloc(count * sizeof(int)); 94 | m_count = count; 95 | } 96 | 97 | void Test::RebuildTopDownSAH() 98 | { 99 | m_tree.Clear(); 100 | 101 | dtTimer timer; 102 | m_tree.BuildTopDownSAH(m_proxies, m_boxes, m_count); 103 | m_buildTime = timer.GetMilliseconds(); 104 | 105 | m_proxyCount = m_tree.GetProxyCount(); 106 | m_nodeCount = m_tree.m_nodeCount; 107 | m_treeHeight = m_tree.GetHeight(); 108 | m_heapCount = m_tree.m_maxHeapCount; 109 | m_treeArea = m_tree.GetAreaRatio(); 110 | 111 | m_base = 0; 112 | } 113 | 114 | void Test::RebuildTopDownMedian() 115 | { 116 | m_tree.Clear(); 117 | 118 | dtTimer timer; 119 | m_tree.BuildTopDownMedianSplit(m_proxies, m_boxes, m_count); 120 | m_buildTime = timer.GetMilliseconds(); 121 | 122 | m_proxyCount = m_tree.GetProxyCount(); 123 | m_nodeCount = m_tree.m_nodeCount; 124 | m_treeHeight = m_tree.GetHeight(); 125 | m_heapCount = m_tree.m_maxHeapCount; 126 | m_treeArea = m_tree.GetAreaRatio(); 127 | 128 | m_base = 0; 129 | } 130 | 131 | void Test::RebuildBottomUp() 132 | { 133 | dtTimer timer; 134 | m_tree.RebuildBottomUp(); 135 | m_buildTime = timer.GetMilliseconds(); 136 | 137 | m_proxyCount = m_tree.GetProxyCount(); 138 | m_nodeCount = m_tree.m_nodeCount; 139 | m_treeHeight = m_tree.GetHeight(); 140 | m_heapCount = m_tree.m_maxHeapCount; 141 | m_treeArea = m_tree.GetAreaRatio(); 142 | 143 | m_base = 0; 144 | } 145 | 146 | Test* g_tests[s_maxTests] = { nullptr }; 147 | int g_testCount = 0; 148 | 149 | int RegisterTest(Test* test) 150 | { 151 | int index = g_testCount; 152 | if (index < s_maxTests) 153 | { 154 | g_tests[index] = test; 155 | ++g_testCount; 156 | return index; 157 | } 158 | 159 | return -1; 160 | } 161 | -------------------------------------------------------------------------------- /samples/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #pragma once 13 | 14 | #include "dynamic-tree/tree.h" 15 | 16 | struct Draw; 17 | 18 | struct Test 19 | { 20 | virtual const char* GetCategory() const = 0; 21 | virtual const char* GetName() const = 0; 22 | virtual void CreateBoxes() = 0; 23 | 24 | void Create(dtInsertionHeuristic heuristic); 25 | void Allocate(int count); 26 | void Destroy(); 27 | virtual void Update(Draw& draw, int reinsertIter, int shuffleIter); 28 | 29 | void RebuildTopDownSAH(); 30 | void RebuildTopDownMedian(); 31 | void RebuildBottomUp(); 32 | 33 | dtAABB* m_boxes; 34 | int* m_proxies; 35 | int m_count; 36 | dtTree m_tree; 37 | int m_base; 38 | float m_buildTime; 39 | 40 | int m_proxyCount = 0; 41 | int m_nodeCount = 0; 42 | int m_treeHeight = 0; 43 | int m_heapCount = 0; 44 | float m_treeArea = 0.0f; 45 | }; 46 | 47 | int RegisterTest(Test* test); 48 | 49 | static const int s_maxTests = 128; 50 | extern Test* g_tests[s_maxTests]; 51 | extern int g_testCount; 52 | -------------------------------------------------------------------------------- /samples/test1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #include "test.h" 13 | 14 | // Single box 15 | struct Test1 : Test 16 | { 17 | const char* GetCategory() const 18 | { 19 | return "Basic"; 20 | } 21 | 22 | const char* GetName() const override 23 | { 24 | return "Single Box"; 25 | } 26 | 27 | void CreateBoxes() override 28 | { 29 | Allocate(1); 30 | 31 | m_boxes[0].lowerBound = dtVecSet(-0.5f, -0.5f, -0.5f); 32 | m_boxes[0].upperBound = dtVecSet(0.5f, 0.5f, 0.5f); 33 | } 34 | }; 35 | 36 | static Test1 s_test; 37 | static int testIndex = RegisterTest(&s_test); 38 | -------------------------------------------------------------------------------- /samples/test2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #include "test.h" 13 | 14 | // Ordered row of boxes 15 | struct Test2 : Test 16 | { 17 | const char* GetCategory() const 18 | { 19 | return "Basic"; 20 | } 21 | 22 | const char* GetName() const override 23 | { 24 | return "Ordered Row"; 25 | } 26 | 27 | void CreateBoxes() override 28 | { 29 | const int count = 1 << 5; 30 | 31 | Allocate(count); 32 | 33 | float x = 0.0f; 34 | for (int i = 0; i < count; ++i) 35 | { 36 | m_boxes[i].lowerBound = dtVecSet(x, 0.0f, 0.0f); 37 | m_boxes[i].upperBound = dtVecSet(x + 1.0f, 1.0f, 1.0f); 38 | x += 1.0f; 39 | } 40 | } 41 | }; 42 | 43 | static Test2 s_test; 44 | static int testIndex = RegisterTest(&s_test); 45 | -------------------------------------------------------------------------------- /samples/test3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #define _CRT_SECURE_NO_WARNINGS 13 | #include "test.h" 14 | #include "draw.h" 15 | #include "imgui/imgui.h" 16 | #include 17 | #include 18 | 19 | struct Test3 : Test 20 | { 21 | enum 22 | { 23 | e_fileCount = 8 24 | }; 25 | 26 | Test3() 27 | { 28 | m_fileIndex = 1; 29 | m_fileNames[0] = "BlizzardLand"; 30 | m_fileNames[1] = "BlizzardLandEditor"; 31 | m_fileNames[2] = "Gibraltar"; 32 | m_fileNames[3] = "Himalayas"; 33 | m_fileNames[4] = "Mexico"; 34 | m_fileNames[5] = "BlizzardLandDynamic"; 35 | m_fileNames[6] = "BlizzardLandKinematic"; 36 | m_fileNames[7] = "BlizzardLandStatic"; 37 | } 38 | 39 | const char* GetCategory() const 40 | { 41 | return "Benchmark"; 42 | } 43 | 44 | const char* GetName() const override 45 | { 46 | return "Overwatch Map"; 47 | } 48 | 49 | void CreateBoxes() override 50 | { 51 | const char* fileName = m_fileNames[m_fileIndex]; 52 | 53 | char filePath[128]; 54 | sprintf_s(filePath, "data/%s.txt", fileName); 55 | 56 | int vertexCount = 0; 57 | 58 | FILE* file = fopen(filePath, "r"); 59 | if (file == nullptr) 60 | { 61 | return; 62 | } 63 | 64 | const int k_bufferSize = 256; 65 | char buffer[k_bufferSize]; 66 | 67 | while (fgets(buffer, k_bufferSize, file)) 68 | { 69 | switch (buffer[0]) 70 | { 71 | case 'v': 72 | ++vertexCount; 73 | break; 74 | } 75 | } 76 | 77 | rewind(file); 78 | 79 | if (vertexCount == 0) 80 | { 81 | fclose(file); 82 | return; 83 | } 84 | 85 | std::vector vertices(vertexCount); 86 | 87 | int index = 0; 88 | while (fgets(buffer, k_bufferSize, file)) 89 | { 90 | float x, y, z; 91 | 92 | switch (buffer[0]) 93 | { 94 | case 'v': 95 | sscanf(buffer, "v %f %f %f", &x, &y, &z); 96 | vertices[index] = dtVecSet(x, y, z); 97 | ++index; 98 | break; 99 | } 100 | } 101 | 102 | fclose(file); 103 | 104 | //vertexCount = dtMin(24, vertexCount); 105 | 106 | Allocate(vertexCount / 2); 107 | 108 | for (int i = 0; i < m_count; ++i) 109 | { 110 | m_boxes[i].lowerBound = vertices[2 * i + 0]; 111 | m_boxes[i].upperBound = vertices[2 * i + 1]; 112 | } 113 | 114 | //m_count = 100; 115 | } 116 | 117 | void Update(Draw& draw, int reinsertIter, int shuffleIter) override 118 | { 119 | if (draw.m_showUI == false) 120 | { 121 | Test::Update(draw, reinsertIter, shuffleIter); 122 | return; 123 | } 124 | 125 | float scale = draw.m_uiScale; 126 | float menuWidth = 150.0f; 127 | ImGui::SetNextWindowPos(ImVec2(10.0f * scale, 300.0f * scale)); 128 | ImGui::SetNextWindowSize(ImVec2(250.0f * scale, 100.0f * scale)); 129 | ImGui::Begin("Test Params", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize); 130 | 131 | if (ImGui::Combo("File", &m_fileIndex, m_fileNames, e_fileCount)) 132 | { 133 | dtInsertionHeuristic heuristic = m_tree.m_heuristic; 134 | Destroy(); 135 | Create(heuristic); 136 | } 137 | 138 | ImGui::End(); 139 | 140 | Test::Update(draw, reinsertIter, shuffleIter); 141 | } 142 | 143 | const char* m_fileNames[e_fileCount]; 144 | int m_fileIndex; 145 | }; 146 | 147 | static Test3 s_test; 148 | static int testIndex = RegisterTest(&s_test); 149 | -------------------------------------------------------------------------------- /samples/test4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #define _CRT_SECURE_NO_WARNINGS 13 | #include "test.h" 14 | #include "draw.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | struct Test4 : Test 21 | { 22 | const char* GetCategory() const 23 | { 24 | return "Benchmark"; 25 | } 26 | 27 | const char* GetName() const override 28 | { 29 | return "Tiled World"; 30 | } 31 | 32 | void CreateBoxes() override 33 | { 34 | const float a = 0.1f; 35 | dtVec r = dtVecSet(a, a, a); 36 | 37 | const int countY = 10; 38 | const int countZ = 200; 39 | const int countP = 20; 40 | 41 | Allocate(countY * countZ + (countP * (countP + 1)) / 2); 42 | 43 | int index = 0; 44 | 45 | // Ground 46 | { 47 | for (int k = 0; k < countY; k++) 48 | { 49 | for (int j = 0; j < countZ; j++) 50 | { 51 | dtVec p = dtVecSet(0.0f, -a - 2.0f * a * k, 2.0f * a * j - (countZ - 1.0f) * a); 52 | dtAABB cube; 53 | cube.lowerBound = p - r; 54 | cube.upperBound = p + r; 55 | m_boxes[index++] = cube; 56 | } 57 | } 58 | } 59 | 60 | // Pyramid 61 | { 62 | dtVec x = dtVecSet(0.0f, a, -(countP - 1.0f) * a); 63 | dtVec deltaX = dtVecSet(0.0f, 2.0f * a, a); 64 | dtVec deltaY = dtVecSet(0.0f, 0.0f, 2.0f * a); 65 | 66 | for (int i = 0; i < countP; ++i) 67 | { 68 | dtVec y = x; 69 | 70 | for (int j = i; j < countP; ++j) 71 | { 72 | dtAABB cube; 73 | cube.lowerBound = y - r; 74 | cube.upperBound = y + r; 75 | m_boxes[index++] = cube; 76 | 77 | y += deltaY; 78 | } 79 | 80 | x += deltaX; 81 | } 82 | } 83 | 84 | assert(index == m_count); 85 | } 86 | }; 87 | 88 | static Test4 s_test; 89 | static int testIndex = RegisterTest(&s_test); 90 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(DYNTREE_SOURCE_FILES 2 | tree.cpp 3 | utils.cpp) 4 | 5 | set(DYNTREE_HEADER_FILES 6 | ../include/dynamic-tree/utils.h 7 | ../include/dynamic-tree/tree.h) 8 | 9 | add_library(dynamic-tree STATIC ${DYNTREE_SOURCE_FILES} ${DYNTREE_HEADER_FILES}) 10 | target_include_directories(dynamic-tree PUBLIC ../include) 11 | -------------------------------------------------------------------------------- /src/utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Erin Catto http://www.box2d.org 3 | * 4 | * Permission to use, copy, modify, distribute and sell this software 5 | * and its documentation for any purpose is hereby granted without fee, 6 | * provided that the above copyright notice appear in all copies. 7 | * Erin Catto makes no representations about the suitability 8 | * of this software for any purpose. 9 | * It is provided "as is" without express or implied warranty. 10 | */ 11 | 12 | #include "dynamic-tree/utils.h" 13 | 14 | #if defined(_WIN32) 15 | 16 | double dtTimer::s_invFrequency = 0.0f; 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif 21 | 22 | #include 23 | 24 | dtTimer::dtTimer() 25 | { 26 | LARGE_INTEGER largeInteger; 27 | 28 | if (s_invFrequency == 0.0f) 29 | { 30 | QueryPerformanceFrequency(&largeInteger); 31 | s_invFrequency = double(largeInteger.QuadPart); 32 | if (s_invFrequency > 0.0f) 33 | { 34 | s_invFrequency = 1000.0f / s_invFrequency; 35 | } 36 | } 37 | 38 | QueryPerformanceCounter(&largeInteger); 39 | m_start = double(largeInteger.QuadPart); 40 | } 41 | 42 | void dtTimer::Reset() 43 | { 44 | LARGE_INTEGER largeInteger; 45 | QueryPerformanceCounter(&largeInteger); 46 | m_start = double(largeInteger.QuadPart); 47 | } 48 | 49 | float dtTimer::GetMilliseconds() const 50 | { 51 | LARGE_INTEGER largeInteger; 52 | QueryPerformanceCounter(&largeInteger); 53 | double count = double(largeInteger.QuadPart); 54 | float ms = float(s_invFrequency * (count - m_start)); 55 | return ms; 56 | } 57 | 58 | #else 59 | 60 | dtTimer::dtTimer() 61 | { 62 | } 63 | 64 | void dtTimer::Reset() 65 | { 66 | } 67 | 68 | float32 dtTimer::GetMilliseconds() const 69 | { 70 | return 0.0f; 71 | } 72 | 73 | #endif 74 | --------------------------------------------------------------------------------