├── .editorconfig ├── .gitignore ├── Heavy ├── core │ ├── hvpch.cpp │ └── hvpch.h ├── extlibs │ ├── box2d │ │ ├── collision │ │ │ ├── b2_broad_phase.cpp │ │ │ ├── b2_chain_shape.cpp │ │ │ ├── b2_circle_shape.cpp │ │ │ ├── b2_collide_circle.cpp │ │ │ ├── b2_collide_edge.cpp │ │ │ ├── b2_collide_polygon.cpp │ │ │ ├── b2_collision.cpp │ │ │ ├── b2_distance.cpp │ │ │ ├── b2_dynamic_tree.cpp │ │ │ ├── b2_edge_shape.cpp │ │ │ ├── b2_polygon_shape.cpp │ │ │ └── b2_time_of_impact.cpp │ │ ├── common │ │ │ ├── b2_block_allocator.cpp │ │ │ ├── b2_draw.cpp │ │ │ ├── b2_math.cpp │ │ │ ├── b2_settings.cpp │ │ │ ├── b2_stack_allocator.cpp │ │ │ └── b2_timer.cpp │ │ ├── dynamics │ │ │ ├── b2_body.cpp │ │ │ ├── b2_chain_circle_contact.cpp │ │ │ ├── b2_chain_circle_contact.h │ │ │ ├── b2_chain_polygon_contact.cpp │ │ │ ├── b2_chain_polygon_contact.h │ │ │ ├── b2_circle_contact.cpp │ │ │ ├── b2_circle_contact.h │ │ │ ├── b2_contact.cpp │ │ │ ├── b2_contact_manager.cpp │ │ │ ├── b2_contact_solver.cpp │ │ │ ├── b2_contact_solver.h │ │ │ ├── b2_distance_joint.cpp │ │ │ ├── b2_edge_circle_contact.cpp │ │ │ ├── b2_edge_circle_contact.h │ │ │ ├── b2_edge_polygon_contact.cpp │ │ │ ├── b2_edge_polygon_contact.h │ │ │ ├── b2_fixture.cpp │ │ │ ├── b2_friction_joint.cpp │ │ │ ├── b2_gear_joint.cpp │ │ │ ├── b2_island.cpp │ │ │ ├── b2_island.h │ │ │ ├── b2_joint.cpp │ │ │ ├── b2_motor_joint.cpp │ │ │ ├── b2_mouse_joint.cpp │ │ │ ├── b2_polygon_circle_contact.cpp │ │ │ ├── b2_polygon_circle_contact.h │ │ │ ├── b2_polygon_contact.cpp │ │ │ ├── b2_polygon_contact.h │ │ │ ├── b2_prismatic_joint.cpp │ │ │ ├── b2_pulley_joint.cpp │ │ │ ├── b2_revolute_joint.cpp │ │ │ ├── b2_weld_joint.cpp │ │ │ ├── b2_wheel_joint.cpp │ │ │ ├── b2_world.cpp │ │ │ └── b2_world_callbacks.cpp │ │ └── rope │ │ │ └── b2_rope.cpp │ └── imgui │ │ ├── imgui-SFML.cpp │ │ ├── imgui.cpp │ │ ├── imgui_draw.cpp │ │ ├── imgui_tables.cpp │ │ └── imgui_widgets.cpp ├── include │ ├── Animator.hpp │ ├── Asset Loader.hpp │ ├── Asset Manager.hpp │ ├── Camera.hpp │ ├── Collider.hpp │ ├── Core.hpp │ ├── Event Dispatcher.hpp │ ├── Fixed Clock.hpp │ ├── Glow Effect.hpp │ ├── Heavy Box2D.hpp │ ├── Heavy Debug.hpp │ ├── Heavy ImGui.hpp │ ├── Heavy Math.hpp │ ├── Heavy Renderer.hpp │ ├── Heavy Times.hpp │ ├── Heavy Utilities.hpp │ ├── Heavy.hpp │ ├── Ini Parser.hpp │ ├── Input.hpp │ ├── Light Renderer.hpp │ ├── Light World.hpp │ ├── Light.hpp │ ├── Particle Emitter.hpp │ ├── Physics World.hpp │ ├── Profile Timer.hpp │ ├── Random.hpp │ ├── Rigid Body.hpp │ ├── Runtime.hpp │ ├── Timer.hpp │ └── b2_draw.hpp ├── premake5.lua └── src │ ├── Animator.cpp │ ├── Asset Loader.cpp │ ├── Asset Manager.cpp │ ├── Camera.cpp │ ├── Collider.cpp │ ├── Event Dispatcher.cpp │ ├── Fixed Clock.cpp │ ├── Glow Effect.cpp │ ├── Heavy Renderer.cpp │ ├── Heavy Times.cpp │ ├── Ini Parser.cpp │ ├── Input.cpp │ ├── Light Renderer.cpp │ ├── Light World.cpp │ ├── Light.cpp │ ├── Particle Emitter.cpp │ ├── Physics World.cpp │ ├── Random.cpp │ ├── Rigid Body.cpp │ ├── Runtime.cpp │ ├── Timer.cpp │ └── b2_draw.cpp ├── Images └── heavy.png ├── README.md ├── Sandbox ├── Application.cpp ├── Application.hpp ├── OptickCore.dll ├── imgui.ini ├── main.cpp ├── openal32.dll ├── premake5.lua ├── res │ ├── bricks.png │ ├── circle_fragment.shader │ ├── circle_vertex.shader │ ├── file.ini │ ├── font.ttf │ ├── gradientFrag.shader │ ├── gradientVert.shader │ ├── heart_fragment.shader │ ├── heart_vertex.shader │ ├── hv_fragment.shader │ ├── hv_vertex.shader │ ├── kuba.png │ ├── light_fragment.shader │ ├── light_vertex.shader │ ├── music.ogg │ ├── numeras.png │ ├── sky.png │ ├── smoke.png │ ├── snow.png │ ├── spritesheet.png │ ├── spritesheetv.png │ ├── texture_fragment.shader │ ├── texture_vertex.shader │ └── tree.png └── temp │ ├── default.vert │ ├── lightShadow.frag │ ├── merge.frag │ └── spot.frag ├── build.bat ├── include ├── ImGui │ ├── imconfig-SFML.h │ ├── imconfig.h │ ├── imgui-SFML.h │ ├── imgui-SFML_export.h │ ├── imgui.h │ ├── imgui_internal.h │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h ├── Optick │ ├── optick.config.h │ ├── optick.h │ ├── optick_capi.h │ ├── optick_common.h │ ├── optick_core.freebsd.h │ ├── optick_core.h │ ├── optick_core.linux.h │ ├── optick_core.macos.h │ ├── optick_core.platform.h │ ├── optick_core.win.h │ ├── optick_gpu.h │ ├── optick_memory.h │ ├── optick_message.h │ ├── optick_miniz.h │ ├── optick_serialization.h │ └── optick_server.h ├── SFML │ ├── Audio.hpp │ ├── Audio │ │ ├── AlResource.hpp │ │ ├── Export.hpp │ │ ├── InputSoundFile.hpp │ │ ├── Listener.hpp │ │ ├── Music.hpp │ │ ├── OutputSoundFile.hpp │ │ ├── Sound.hpp │ │ ├── SoundBuffer.hpp │ │ ├── SoundBufferRecorder.hpp │ │ ├── SoundFileFactory.hpp │ │ ├── SoundFileFactory.inl │ │ ├── SoundFileReader.hpp │ │ ├── SoundFileWriter.hpp │ │ ├── SoundRecorder.hpp │ │ ├── SoundSource.hpp │ │ └── SoundStream.hpp │ ├── Config.hpp │ ├── GpuPreference.hpp │ ├── Graphics.hpp │ ├── Graphics │ │ ├── BlendMode.hpp │ │ ├── CircleShape.hpp │ │ ├── Color.hpp │ │ ├── ConvexShape.hpp │ │ ├── Drawable.hpp │ │ ├── Export.hpp │ │ ├── Font.hpp │ │ ├── Glsl.hpp │ │ ├── Glsl.inl │ │ ├── Glyph.hpp │ │ ├── Image.hpp │ │ ├── PrimitiveType.hpp │ │ ├── Rect.hpp │ │ ├── Rect.inl │ │ ├── RectangleShape.hpp │ │ ├── RenderStates.hpp │ │ ├── RenderTarget.hpp │ │ ├── RenderTexture.hpp │ │ ├── RenderWindow.hpp │ │ ├── Shader.hpp │ │ ├── Shape.hpp │ │ ├── Sprite.hpp │ │ ├── Text.hpp │ │ ├── Texture.hpp │ │ ├── Transform.hpp │ │ ├── Transformable.hpp │ │ ├── Vertex.hpp │ │ ├── VertexArray.hpp │ │ ├── VertexBuffer.hpp │ │ └── View.hpp │ ├── Main.hpp │ ├── Network.hpp │ ├── Network │ │ ├── Export.hpp │ │ ├── Ftp.hpp │ │ ├── Http.hpp │ │ ├── IpAddress.hpp │ │ ├── Packet.hpp │ │ ├── Socket.hpp │ │ ├── SocketHandle.hpp │ │ ├── SocketSelector.hpp │ │ ├── TcpListener.hpp │ │ ├── TcpSocket.hpp │ │ └── UdpSocket.hpp │ ├── OpenGL.hpp │ ├── System.hpp │ ├── System │ │ ├── Clock.hpp │ │ ├── Err.hpp │ │ ├── Export.hpp │ │ ├── FileInputStream.hpp │ │ ├── InputStream.hpp │ │ ├── Lock.hpp │ │ ├── MemoryInputStream.hpp │ │ ├── Mutex.hpp │ │ ├── NativeActivity.hpp │ │ ├── NonCopyable.hpp │ │ ├── Sleep.hpp │ │ ├── String.hpp │ │ ├── String.inl │ │ ├── Thread.hpp │ │ ├── Thread.inl │ │ ├── ThreadLocal.hpp │ │ ├── ThreadLocalPtr.hpp │ │ ├── ThreadLocalPtr.inl │ │ ├── Time.hpp │ │ ├── Utf.hpp │ │ ├── Utf.inl │ │ ├── Vector2.hpp │ │ ├── Vector2.inl │ │ ├── Vector3.hpp │ │ └── Vector3.inl │ ├── Window.hpp │ └── Window │ │ ├── Clipboard.hpp │ │ ├── Context.hpp │ │ ├── ContextSettings.hpp │ │ ├── Cursor.hpp │ │ ├── Event.hpp │ │ ├── Export.hpp │ │ ├── GlResource.hpp │ │ ├── Joystick.hpp │ │ ├── Keyboard.hpp │ │ ├── Mouse.hpp │ │ ├── Sensor.hpp │ │ ├── Touch.hpp │ │ ├── VideoMode.hpp │ │ ├── Vulkan.hpp │ │ ├── Window.hpp │ │ ├── WindowBase.hpp │ │ ├── WindowHandle.hpp │ │ └── WindowStyle.hpp └── box2d │ ├── b2_api.h │ ├── b2_block_allocator.h │ ├── b2_body.h │ ├── b2_broad_phase.h │ ├── b2_chain_shape.h │ ├── b2_circle_shape.h │ ├── b2_collision.h │ ├── b2_common.h │ ├── b2_contact.h │ ├── b2_contact_manager.h │ ├── b2_distance.h │ ├── b2_distance_joint.h │ ├── b2_draw.h │ ├── b2_dynamic_tree.h │ ├── b2_edge_shape.h │ ├── b2_fixture.h │ ├── b2_friction_joint.h │ ├── b2_gear_joint.h │ ├── b2_growable_stack.h │ ├── b2_joint.h │ ├── b2_math.h │ ├── b2_motor_joint.h │ ├── b2_mouse_joint.h │ ├── b2_polygon_shape.h │ ├── b2_prismatic_joint.h │ ├── b2_pulley_joint.h │ ├── b2_revolute_joint.h │ ├── b2_rope.h │ ├── b2_settings.h │ ├── b2_shape.h │ ├── b2_stack_allocator.h │ ├── b2_time_of_impact.h │ ├── b2_time_step.h │ ├── b2_timer.h │ ├── b2_types.h │ ├── b2_weld_joint.h │ ├── b2_wheel_joint.h │ ├── b2_world.h │ ├── b2_world_callbacks.h │ └── box2d.h ├── libs ├── Optick │ └── lib │ │ ├── Debug │ │ └── OptickCore.lib │ │ └── Release │ │ └── OptickCore.lib └── SFML │ ├── extlibs │ ├── flac.lib │ ├── freetype.lib │ ├── ogg.lib │ ├── openal32.lib │ ├── vorbis.lib │ ├── vorbisenc.lib │ └── vorbisfile.lib │ └── lib │ ├── Debug │ ├── sfml-audio-s-d.lib │ ├── sfml-graphics-s-d.lib │ ├── sfml-main-d.lib │ ├── sfml-network-s-d.lib │ ├── sfml-system-s-d.lib │ └── sfml-window-s-d.lib │ ├── PDB │ ├── sfml-audio-s-d.pdb │ ├── sfml-audio-s.pdb │ ├── sfml-graphics-s-d.pdb │ ├── sfml-graphics-s.pdb │ ├── sfml-main-d.pdb │ ├── sfml-main-s.pdb │ ├── sfml-network-s-d.pdb │ ├── sfml-network-s.pdb │ ├── sfml-system-s-d.pdb │ ├── sfml-system-s.pdb │ ├── sfml-window-s-d.pdb │ └── sfml-window-s.pdb │ └── Release │ ├── sfml-audio-s.lib │ ├── sfml-graphics-s.lib │ ├── sfml-main.lib │ ├── sfml-network-s.lib │ ├── sfml-system-s.lib │ └── sfml-window-s.lib ├── premake5.lua └── vendor ├── license.readme └── premake5.exe /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries 2 | **/bin/ 3 | 4 | # Visual Studio files and folder 5 | .vs/ 6 | **.sln 7 | **.vcxproj 8 | **.vcxproj.filters 9 | **.vcxproj.user -------------------------------------------------------------------------------- /Heavy/core/hvpch.cpp: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /Heavy/core/hvpch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "Core.hpp" 20 | 21 | #include -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/common/b2_draw.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | #include "box2d/b2_draw.h" 23 | 24 | b2Draw::b2Draw() 25 | { 26 | m_drawFlags = 0; 27 | } 28 | 29 | void b2Draw::SetFlags(uint32 flags) 30 | { 31 | m_drawFlags = flags; 32 | } 33 | 34 | uint32 b2Draw::GetFlags() const 35 | { 36 | return m_drawFlags; 37 | } 38 | 39 | void b2Draw::AppendFlags(uint32 flags) 40 | { 41 | m_drawFlags |= flags; 42 | } 43 | 44 | void b2Draw::ClearFlags(uint32 flags) 45 | { 46 | m_drawFlags &= ~flags; 47 | } 48 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/common/b2_settings.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #define _CRT_SECURE_NO_WARNINGS 24 | 25 | #include "box2d/b2_settings.h" 26 | #include 27 | #include 28 | #include 29 | 30 | b2Version b2_version = {2, 4, 0}; 31 | 32 | // Memory allocators. Modify these to use your own allocator. 33 | void* b2Alloc_Default(int32 size) 34 | { 35 | return malloc(size); 36 | } 37 | 38 | void b2Free_Default(void* mem) 39 | { 40 | free(mem); 41 | } 42 | 43 | // You can modify this to use your logging facility. 44 | void b2Log_Default(const char* string, va_list args) 45 | { 46 | vprintf(string, args); 47 | } 48 | 49 | FILE* b2_dumpFile = nullptr; 50 | 51 | void b2OpenDump(const char* fileName) 52 | { 53 | b2Assert(b2_dumpFile == nullptr); 54 | b2_dumpFile = fopen(fileName, "w"); 55 | } 56 | 57 | void b2Dump(const char* string, ...) 58 | { 59 | if (b2_dumpFile == nullptr) 60 | { 61 | return; 62 | } 63 | 64 | va_list args; 65 | va_start(args, string); 66 | vfprintf(b2_dumpFile, string, args); 67 | va_end(args); 68 | } 69 | 70 | void b2CloseDump() 71 | { 72 | fclose(b2_dumpFile); 73 | b2_dumpFile = nullptr; 74 | } 75 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/common/b2_stack_allocator.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/b2_stack_allocator.h" 24 | #include "box2d/b2_math.h" 25 | 26 | b2StackAllocator::b2StackAllocator() 27 | { 28 | m_index = 0; 29 | m_allocation = 0; 30 | m_maxAllocation = 0; 31 | m_entryCount = 0; 32 | } 33 | 34 | b2StackAllocator::~b2StackAllocator() 35 | { 36 | b2Assert(m_index == 0); 37 | b2Assert(m_entryCount == 0); 38 | } 39 | 40 | void* b2StackAllocator::Allocate(int32 size) 41 | { 42 | b2Assert(m_entryCount < b2_maxStackEntries); 43 | 44 | b2StackEntry* entry = m_entries + m_entryCount; 45 | entry->size = size; 46 | if (m_index + size > b2_stackSize) 47 | { 48 | entry->data = (char*)b2Alloc(size); 49 | entry->usedMalloc = true; 50 | } 51 | else 52 | { 53 | entry->data = m_data + m_index; 54 | entry->usedMalloc = false; 55 | m_index += size; 56 | } 57 | 58 | m_allocation += size; 59 | m_maxAllocation = b2Max(m_maxAllocation, m_allocation); 60 | ++m_entryCount; 61 | 62 | return entry->data; 63 | } 64 | 65 | void b2StackAllocator::Free(void* p) 66 | { 67 | b2Assert(m_entryCount > 0); 68 | b2StackEntry* entry = m_entries + m_entryCount - 1; 69 | b2Assert(p == entry->data); 70 | if (entry->usedMalloc) 71 | { 72 | b2Free(p); 73 | } 74 | else 75 | { 76 | m_index -= entry->size; 77 | } 78 | m_allocation -= entry->size; 79 | --m_entryCount; 80 | 81 | p = nullptr; 82 | } 83 | 84 | int32 b2StackAllocator::GetMaxAllocation() const 85 | { 86 | return m_maxAllocation; 87 | } 88 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_chain_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_chain_circle_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_fixture.h" 26 | #include "box2d/b2_chain_shape.h" 27 | #include "box2d/b2_edge_shape.h" 28 | 29 | #include 30 | 31 | b2Contact* b2ChainAndCircleContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) 32 | { 33 | void* mem = allocator->Allocate(sizeof(b2ChainAndCircleContact)); 34 | return new (mem) b2ChainAndCircleContact(fixtureA, indexA, fixtureB, indexB); 35 | } 36 | 37 | void b2ChainAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 38 | { 39 | ((b2ChainAndCircleContact*)contact)->~b2ChainAndCircleContact(); 40 | allocator->Free(contact, sizeof(b2ChainAndCircleContact)); 41 | } 42 | 43 | b2ChainAndCircleContact::b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) 44 | : b2Contact(fixtureA, indexA, fixtureB, indexB) 45 | { 46 | b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); 47 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 48 | } 49 | 50 | void b2ChainAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 51 | { 52 | b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); 53 | b2EdgeShape edge; 54 | chain->GetChildEdge(&edge, m_indexA); 55 | b2CollideEdgeAndCircle( manifold, &edge, xfA, 56 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_chain_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CHAIN_AND_CIRCLE_CONTACT_H 24 | #define B2_CHAIN_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2ChainAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 38 | ~b2ChainAndCircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_chain_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_chain_polygon_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_fixture.h" 26 | #include "box2d/b2_chain_shape.h" 27 | #include "box2d/b2_edge_shape.h" 28 | 29 | #include 30 | 31 | b2Contact* b2ChainAndPolygonContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) 32 | { 33 | void* mem = allocator->Allocate(sizeof(b2ChainAndPolygonContact)); 34 | return new (mem) b2ChainAndPolygonContact(fixtureA, indexA, fixtureB, indexB); 35 | } 36 | 37 | void b2ChainAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 38 | { 39 | ((b2ChainAndPolygonContact*)contact)->~b2ChainAndPolygonContact(); 40 | allocator->Free(contact, sizeof(b2ChainAndPolygonContact)); 41 | } 42 | 43 | b2ChainAndPolygonContact::b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) 44 | : b2Contact(fixtureA, indexA, fixtureB, indexB) 45 | { 46 | b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); 47 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 48 | } 49 | 50 | void b2ChainAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 51 | { 52 | b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); 53 | b2EdgeShape edge; 54 | chain->GetChildEdge(&edge, m_indexA); 55 | b2CollideEdgeAndPolygon( manifold, &edge, xfA, 56 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_chain_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CHAIN_AND_POLYGON_CONTACT_H 24 | #define B2_CHAIN_AND_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2ChainAndPolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 38 | ~b2ChainAndPolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_circle_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_body.h" 26 | #include "box2d/b2_fixture.h" 27 | #include "box2d/b2_time_of_impact.h" 28 | #include "box2d/b2_world_callbacks.h" 29 | 30 | #include 31 | 32 | b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 33 | { 34 | void* mem = allocator->Allocate(sizeof(b2CircleContact)); 35 | return new (mem) b2CircleContact(fixtureA, fixtureB); 36 | } 37 | 38 | void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 39 | { 40 | ((b2CircleContact*)contact)->~b2CircleContact(); 41 | allocator->Free(contact, sizeof(b2CircleContact)); 42 | } 43 | 44 | b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 45 | : b2Contact(fixtureA, 0, fixtureB, 0) 46 | { 47 | b2Assert(m_fixtureA->GetType() == b2Shape::e_circle); 48 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 49 | } 50 | 51 | void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 52 | { 53 | b2CollideCircles(manifold, 54 | (b2CircleShape*)m_fixtureA->GetShape(), xfA, 55 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 56 | } 57 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CIRCLE_CONTACT_H 24 | #define B2_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2CircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2CircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_contact_solver.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CONTACT_SOLVER_H 24 | #define B2_CONTACT_SOLVER_H 25 | 26 | #include "box2d/b2_collision.h" 27 | #include "box2d/b2_math.h" 28 | #include "box2d/b2_time_step.h" 29 | 30 | class b2Contact; 31 | class b2Body; 32 | class b2StackAllocator; 33 | struct b2ContactPositionConstraint; 34 | 35 | struct b2VelocityConstraintPoint 36 | { 37 | b2Vec2 rA; 38 | b2Vec2 rB; 39 | float normalImpulse; 40 | float tangentImpulse; 41 | float normalMass; 42 | float tangentMass; 43 | float velocityBias; 44 | }; 45 | 46 | struct b2ContactVelocityConstraint 47 | { 48 | b2VelocityConstraintPoint points[b2_maxManifoldPoints]; 49 | b2Vec2 normal; 50 | b2Mat22 normalMass; 51 | b2Mat22 K; 52 | int32 indexA; 53 | int32 indexB; 54 | float invMassA, invMassB; 55 | float invIA, invIB; 56 | float friction; 57 | float restitution; 58 | float threshold; 59 | float tangentSpeed; 60 | int32 pointCount; 61 | int32 contactIndex; 62 | }; 63 | 64 | struct b2ContactSolverDef 65 | { 66 | b2TimeStep step; 67 | b2Contact** contacts; 68 | int32 count; 69 | b2Position* positions; 70 | b2Velocity* velocities; 71 | b2StackAllocator* allocator; 72 | }; 73 | 74 | class b2ContactSolver 75 | { 76 | public: 77 | b2ContactSolver(b2ContactSolverDef* def); 78 | ~b2ContactSolver(); 79 | 80 | void InitializeVelocityConstraints(); 81 | 82 | void WarmStart(); 83 | void SolveVelocityConstraints(); 84 | void StoreImpulses(); 85 | 86 | bool SolvePositionConstraints(); 87 | bool SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB); 88 | 89 | b2TimeStep m_step; 90 | b2Position* m_positions; 91 | b2Velocity* m_velocities; 92 | b2StackAllocator* m_allocator; 93 | b2ContactPositionConstraint* m_positionConstraints; 94 | b2ContactVelocityConstraint* m_velocityConstraints; 95 | b2Contact** m_contacts; 96 | int m_count; 97 | }; 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_edge_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_edge_circle_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact)); 33 | return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact(); 39 | allocator->Free(contact, sizeof(b2EdgeAndCircleContact)); 40 | } 41 | 42 | b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 47 | } 48 | 49 | void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollideEdgeAndCircle( manifold, 52 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 53 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_edge_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_EDGE_AND_CIRCLE_CONTACT_H 24 | #define B2_EDGE_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2EdgeAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2EdgeAndCircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_edge_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_edge_polygon_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact)); 33 | return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact(); 39 | allocator->Free(contact, sizeof(b2EdgeAndPolygonContact)); 40 | } 41 | 42 | b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 47 | } 48 | 49 | void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollideEdgeAndPolygon( manifold, 52 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 53 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_edge_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_EDGE_AND_POLYGON_CONTACT_H 24 | #define B2_EDGE_AND_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2EdgeAndPolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2EdgeAndPolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_island.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_ISLAND_H 24 | #define B2_ISLAND_H 25 | 26 | #include "box2d/b2_body.h" 27 | #include "box2d/b2_math.h" 28 | #include "box2d/b2_time_step.h" 29 | 30 | class b2Contact; 31 | class b2Joint; 32 | class b2StackAllocator; 33 | class b2ContactListener; 34 | struct b2ContactVelocityConstraint; 35 | struct b2Profile; 36 | 37 | /// This is an internal class. 38 | class b2Island 39 | { 40 | public: 41 | b2Island(int32 bodyCapacity, int32 contactCapacity, int32 jointCapacity, 42 | b2StackAllocator* allocator, b2ContactListener* listener); 43 | ~b2Island(); 44 | 45 | void Clear() 46 | { 47 | m_bodyCount = 0; 48 | m_contactCount = 0; 49 | m_jointCount = 0; 50 | } 51 | 52 | void Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep); 53 | 54 | void SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB); 55 | 56 | void Add(b2Body* body) 57 | { 58 | b2Assert(m_bodyCount < m_bodyCapacity); 59 | body->m_islandIndex = m_bodyCount; 60 | m_bodies[m_bodyCount] = body; 61 | ++m_bodyCount; 62 | } 63 | 64 | void Add(b2Contact* contact) 65 | { 66 | b2Assert(m_contactCount < m_contactCapacity); 67 | m_contacts[m_contactCount++] = contact; 68 | } 69 | 70 | void Add(b2Joint* joint) 71 | { 72 | b2Assert(m_jointCount < m_jointCapacity); 73 | m_joints[m_jointCount++] = joint; 74 | } 75 | 76 | void Report(const b2ContactVelocityConstraint* constraints); 77 | 78 | b2StackAllocator* m_allocator; 79 | b2ContactListener* m_listener; 80 | 81 | b2Body** m_bodies; 82 | b2Contact** m_contacts; 83 | b2Joint** m_joints; 84 | 85 | b2Position* m_positions; 86 | b2Velocity* m_velocities; 87 | 88 | int32 m_bodyCount; 89 | int32 m_jointCount; 90 | int32 m_contactCount; 91 | 92 | int32 m_bodyCapacity; 93 | int32 m_contactCapacity; 94 | int32 m_jointCapacity; 95 | }; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_polygon_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_polygon_circle_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact)); 33 | return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact(); 39 | allocator->Free(contact, sizeof(b2PolygonAndCircleContact)); 40 | } 41 | 42 | b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 47 | } 48 | 49 | void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollidePolygonAndCircle( manifold, 52 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 53 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_polygon_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H 24 | #define B2_POLYGON_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2PolygonAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 34 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 35 | 36 | b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 37 | ~b2PolygonAndCircleContact() {} 38 | 39 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_polygon_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_body.h" 27 | #include "box2d/b2_fixture.h" 28 | #include "box2d/b2_time_of_impact.h" 29 | #include "box2d/b2_world_callbacks.h" 30 | 31 | #include 32 | 33 | b2Contact* b2PolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 34 | { 35 | void* mem = allocator->Allocate(sizeof(b2PolygonContact)); 36 | return new (mem) b2PolygonContact(fixtureA, fixtureB); 37 | } 38 | 39 | void b2PolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 40 | { 41 | ((b2PolygonContact*)contact)->~b2PolygonContact(); 42 | allocator->Free(contact, sizeof(b2PolygonContact)); 43 | } 44 | 45 | b2PolygonContact::b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 46 | : b2Contact(fixtureA, 0, fixtureB, 0) 47 | { 48 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 49 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 50 | } 51 | 52 | void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 53 | { 54 | b2CollidePolygons( manifold, 55 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 56 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_POLYGON_CONTACT_H 24 | #define B2_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2PolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2PolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Heavy/extlibs/box2d/dynamics/b2_world_callbacks.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/b2_fixture.h" 24 | #include "box2d/b2_world_callbacks.h" 25 | 26 | // Return true if contact calculations should be performed between these two shapes. 27 | // If you implement your own collision filter you may want to build from this implementation. 28 | bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB) 29 | { 30 | const b2Filter& filterA = fixtureA->GetFilterData(); 31 | const b2Filter& filterB = fixtureB->GetFilterData(); 32 | 33 | if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) 34 | { 35 | return filterA.groupIndex > 0; 36 | } 37 | 38 | bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; 39 | return collide; 40 | } 41 | -------------------------------------------------------------------------------- /Heavy/include/Animator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace hv { 8 | struct Animation; 9 | 10 | class Animator { 11 | public: 12 | float DefaultSpeed = 0.0f; 13 | 14 | Animator(); 15 | 16 | Animator(float defaultSpeed); 17 | 18 | ~Animator(); 19 | 20 | void Play(Animation& animation); 21 | 22 | bool IsPlaying(const Animation& animation); 23 | 24 | private: 25 | 26 | void Update(Animation& animation); 27 | void UpdateReverse(Animation& animation); 28 | 29 | bool Check(const Animation& animation); 30 | 31 | float m_animationSpeed = 0.0f; 32 | }; 33 | } 34 | 35 | namespace hv { 36 | enum class SpriteSheet { RightDown = 0, DownRight }; 37 | 38 | struct Animation 39 | { 40 | float Speed = 0.0f; 41 | 42 | bool PlayOnce = false; 43 | bool Reversed = false; 44 | bool Playable = true; 45 | 46 | int32_t CurrentFrame = 0; 47 | uint32_t FrameCount = 0; 48 | 49 | uint32_t FrameWidth = 0; 50 | uint32_t FrameHeight = 0; 51 | 52 | sf::Sprite* Sprite = nullptr; 53 | sf::IntRect* Frames = nullptr; 54 | 55 | SpriteSheet Mode = SpriteSheet::RightDown; 56 | 57 | std::function Function = 0; 58 | 59 | void Create(uint32_t frameCountX, uint32_t frameCountY, uint32_t offset = 0, 60 | sf::Sprite* sprite = nullptr, sf::Texture* texture = nullptr); 61 | 62 | void ApplyFrame(const sf::IntRect& frame); 63 | 64 | void Restart(bool frame = false); 65 | 66 | void GetImGuiInfo(const char* tabName); 67 | 68 | Animation(); 69 | ~Animation(); 70 | 71 | private: 72 | float m_elapsedTime = 0.0f; 73 | 74 | friend class Animator; 75 | }; 76 | } -------------------------------------------------------------------------------- /Heavy/include/Asset Loader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Asset Loader.hpp 5 | Singleton class responsible for asynchronous asset load 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "Core.hpp" 15 | 16 | namespace hv { 17 | enum class AssetType 18 | { 19 | Texture = 0, 20 | Font, 21 | Music, 22 | Sound, 23 | Shader, 24 | MemoryShader, 25 | }; 26 | 27 | class AssetLoader { 28 | public: 29 | static AssetLoader& Get(); 30 | 31 | // This function synchronizes all threads 32 | void Sync(); 33 | 34 | // You can load only one type of resource at the call of this function 35 | // if you are using it to load shader fragment always must be on the left side! 36 | void AddResource(std::string name, std::string path, AssetType type); 37 | void AddResource(const std::string& name, const std::string& fragment, const std::string& vertex, AssetType type); 38 | private: 39 | AssetLoader(); 40 | ~AssetLoader(); 41 | 42 | struct Resource 43 | { 44 | void(*Fun)(void*, std::string) = 0; 45 | void* Raw = 0; 46 | }; 47 | 48 | std::stack> m_Results; 49 | 50 | Resource GetResource(const std::string& name, const AssetType& type); 51 | 52 | static void LoadTexture (void* res, std::string path); 53 | static void LoadFont (void* res, std::string path); 54 | static void LoadMusic (void* res, std::string path); 55 | static void LoadSound (void* res, std::string path); 56 | 57 | static void LoadShader (sf::Shader* res, std::string fragment, std::string vertex); 58 | static void LoadShaderFromMemory(sf::Shader* res, std::string fragment, std::string vertex); 59 | 60 | static AssetLoader s_instance; 61 | }; 62 | } -------------------------------------------------------------------------------- /Heavy/include/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Camera.hpp 5 | Singleton class responsible for camera and it's effects 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace hv { 14 | class Camera { 15 | public: 16 | static Camera& Get(); 17 | void Init(sf::RenderWindow* window); 18 | 19 | void Update(); 20 | 21 | // Cammera shake effect 22 | void Shake(float time, int power); 23 | 24 | // Modifiers 25 | void Move(sf::Vector2f offset); 26 | 27 | // Accessors 28 | sf::Vector2f GetCenter() const; 29 | sf::Vector2f GetSize() const; 30 | 31 | private: 32 | Camera(); 33 | ~Camera(); 34 | 35 | struct ShakeContext 36 | { 37 | sf::Vector2f Center; 38 | sf::Vector2f Pos[6]; 39 | uint32_t CurrentPos = 0; 40 | 41 | void CreatePos(const int& power); 42 | }; 43 | 44 | sf::View m_view; 45 | sf::RenderWindow* m_window = nullptr; 46 | 47 | float m_shakeElapsedTime = 0.0f; 48 | float m_shakeTime = 0.0f; 49 | 50 | static Camera s_instance; 51 | 52 | void ApplyEffects(); 53 | void Shake(); 54 | ShakeContext m_sc; 55 | 56 | void Resize(const sf::Vector2f& size); 57 | 58 | Mat4x4 Projection; 59 | }; 60 | } -------------------------------------------------------------------------------- /Heavy/include/Collider.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Collider.hpp 5 | */ 6 | 7 | #include 8 | #include "Heavy Box2D.hpp" 9 | #include 10 | 11 | namespace hv { 12 | class RigidBody; 13 | 14 | namespace Constants { 15 | constexpr float PPM = 30.0f; // Pixel per meter 16 | } 17 | } 18 | 19 | namespace hv { 20 | class Collider { 21 | public: 22 | Collider(); 23 | virtual ~Collider(); 24 | 25 | virtual void SetTriggered(bool triggered); 26 | 27 | std::function Function; 28 | 29 | protected: 30 | b2FixtureDef i_fixtureDef; 31 | 32 | friend class RigidBody; 33 | }; 34 | } 35 | 36 | namespace hv { 37 | struct BoxCollider : public Collider { 38 | public: 39 | BoxCollider(); 40 | 41 | BoxCollider(sf::Vector2f size); 42 | 43 | ~BoxCollider(); 44 | 45 | void SetSize(sf::Vector2f size); 46 | 47 | private: 48 | b2PolygonShape m_shape; 49 | }; 50 | } 51 | 52 | namespace hv { 53 | struct CircleCollider : public Collider { 54 | public: 55 | CircleCollider(); 56 | 57 | CircleCollider(float radius); 58 | 59 | ~CircleCollider(); 60 | 61 | // Modifiers 62 | 63 | void SetRadius(float radius); 64 | 65 | private: 66 | b2CircleShape m_shape; 67 | }; 68 | } 69 | 70 | namespace hv { 71 | struct EdgeCollider : public Collider { 72 | public: 73 | EdgeCollider(); 74 | 75 | ~EdgeCollider(); 76 | 77 | // Modifiers 78 | void AddPoints(sf::Vector2f start, sf::Vector2f end); 79 | private: 80 | b2EdgeShape m_shape; 81 | b2Body* m_body; 82 | }; 83 | } 84 | 85 | namespace hv { 86 | class ContactListener : public b2ContactListener { 87 | public: 88 | virtual void BeginContact(b2Contact* contact); 89 | virtual void EndContact(b2Contact* contact); 90 | }; 91 | } -------------------------------------------------------------------------------- /Heavy/include/Core.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Core definitions for Heavy Engine 5 | Every key macro or function should be placed here 6 | */ 7 | 8 | // Disables enum class warning 9 | #pragma warning(disable: 26812) 10 | 11 | // Linker /ignore:4006 removes warning that optick and SFML gave 12 | 13 | #define ENABLE_IMGUI 1 14 | #define DISABLE_PROFILING 0 15 | #define DISABLE_CONSOLE 0 16 | 17 | #if DISABLE_PROFILING 18 | #define HV_PROFILE_FRAME(...) 19 | #define HV_PROFILE_FUNC(...) 20 | #define HV_PROFILE_TAG(NAME, ...) 21 | #define HV_PROFILE_THREAD(...) 22 | #define HV_PROFILE_SCOPE_DYNAMIC(NAME) 23 | #define HV_LOG(...) 24 | #define HV_ASSERT(VAR) VAR 25 | #define HV_DEBUG_ASSERT(VAR) 26 | #define HV_TIME_FUNC(NAME) 27 | 28 | #else 29 | #include 30 | #include 31 | #include "../include/Profile Timer.hpp" 32 | 33 | #define HV_PROFILE_FRAME(...) OPTICK_FRAME(__VA_ARGS__) 34 | #define HV_PROFILE_FUNC(...) OPTICK_EVENT(__VA_ARGS__) 35 | #define HV_PROFILE_TAG(NAME, ...) OPTICK_TAG(NAME, __VA_ARGS__) 36 | #define HV_PROFILE_THREAD(...) OPTICK_THREAD(__VA_ARGS__) 37 | #define HV_PROFILE_SCOPE_DYNAMIC(NAME) OPTICK_EVENT_DYNAMIC(NAME) 38 | #define HV_LOG(...) DEBUG_MESSAGE_LOG(__VA_ARGS__) 39 | #define HV_ASSERT(VAR) if(!(VAR)) __debugbreak(); 40 | #define HV_DEBUG_ASSERT(VAR) if(!(VAR)) __debugbreak(); 41 | #define HV_TIME_FUNC(NAME) hv::ProfileTimer NAME(#NAME) 42 | 43 | template 44 | constexpr static void DEBUG_MESSAGE_LOG(Args&&... args) 45 | { 46 | (std::cout << ... << args); 47 | } 48 | 49 | #endif 50 | 51 | #if DISABLE_CONSOLE 52 | #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") 53 | #endif 54 | -------------------------------------------------------------------------------- /Heavy/include/Event Dispatcher.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Event Dispatcher.hpp 5 | Class giving access to last event 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace hv { 14 | class EventDispatcher { 15 | public: 16 | static void Init(bool& focus); 17 | 18 | static void DispatchEvent(const sf::Event& event); 19 | 20 | static sf::Event GetEvent(sf::Event::EventType type); 21 | static bool CheckFor(sf::Event::EventType event); 22 | static void Clear(); 23 | 24 | private: 25 | static bool* s_focus; 26 | static std::unordered_map s_events; 27 | }; 28 | } -------------------------------------------------------------------------------- /Heavy/include/Fixed Clock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | Fixed Clock.hpp 7 | Fixed Clcok measuring time based on delta time of application 8 | */ 9 | 10 | namespace hv { 11 | class FixedClock { 12 | public: 13 | FixedClock(bool start); 14 | ~FixedClock(); 15 | 16 | void Start(); 17 | void Stop(); 18 | void Restart(); 19 | 20 | sf::Time GetElapsedTime() const; 21 | private: 22 | sf::Clock m_clock; 23 | sf::Time m_stoppedTime = sf::Time::Zero; 24 | bool m_running = false; 25 | }; 26 | } -------------------------------------------------------------------------------- /Heavy/include/Glow Effect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace hv { 8 | class GlowEffect : public sf::Drawable { 9 | public: 10 | GlowEffect(); 11 | ~GlowEffect(); 12 | 13 | void SetRadius(float radius); 14 | void SetPosition(sf::Vector2f pos); 15 | 16 | sf::Color Color = sf::Color(255, 255, 255); 17 | private: 18 | sf::Vertex m_vertices[6]; 19 | 20 | static sf::Shader* s_shader; 21 | sf::Vector2f m_position; 22 | float m_radius = 0.0f; 23 | 24 | struct ShaderSource 25 | { 26 | static const std::string Fragment; 27 | static const std::string Vertex; 28 | }; 29 | 30 | void TranslateVertices(); 31 | 32 | virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const; 33 | }; 34 | } -------------------------------------------------------------------------------- /Heavy/include/Heavy Box2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #pragma warning( push ) 4 | #pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS ) 5 | #include 6 | #pragma warning( pop ) -------------------------------------------------------------------------------- /Heavy/include/Heavy Debug.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Heavy Debug.hpp 5 | Class giving colored output to console 6 | */ 7 | 8 | #include 9 | 10 | namespace hv { 11 | enum class Color 12 | { 13 | Red = 0, 14 | Green, 15 | Yellow, 16 | Blue, 17 | }; 18 | 19 | class Debug { 20 | public: 21 | // Color log function 22 | template 23 | constexpr static void Log(Color color, Args&&... args) { 24 | std::cout << ColorAnsi(color); 25 | (std::cerr << ... << args); 26 | std::cout << "\033[0m"; 27 | } 28 | 29 | private: 30 | static const char* ColorAnsi(Color color) { 31 | switch (color) { 32 | case Color::Red: 33 | return "\x1B[31m"; 34 | case Color::Green: 35 | return "\x1B[32m"; 36 | case Color::Yellow: 37 | return "\x1B[33m"; 38 | case Color::Blue: 39 | return "\x1B[34m"; 40 | } 41 | 42 | return ""; 43 | } 44 | }; 45 | } -------------------------------------------------------------------------------- /Heavy/include/Heavy ImGui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | "Heavy" way to implement ImGui 5 | */ 6 | 7 | #include "Core.hpp" 8 | 9 | #if ENABLE_IMGUI 10 | #include 11 | #include 12 | #endif -------------------------------------------------------------------------------- /Heavy/include/Heavy Renderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace hv { 8 | class Renderer : private sf::RenderTexture { 9 | public: 10 | using sf::RenderTexture::draw; 11 | using sf::RenderTexture::display; 12 | 13 | sf::Color ClearColor; 14 | 15 | Renderer(); 16 | ~Renderer(); 17 | 18 | void Resize(sf::Vector2u size); 19 | 20 | void clear(); 21 | 22 | const sf::Sprite& GetFrame(); 23 | 24 | private: 25 | typedef sf::RenderTexture m_frame; 26 | 27 | sf::Sprite m_frameSprite; 28 | }; 29 | } -------------------------------------------------------------------------------- /Heavy/include/Heavy Times.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't ask why this class is in here just don't delete it 4 | 5 | namespace hv { 6 | class Runtime; 7 | 8 | struct Times { 9 | static Times Instance; 10 | 11 | float DT = 0.0f; 12 | float FDT = 0.0f; 13 | 14 | friend class Runtime; 15 | }; 16 | 17 | extern const float& dt; 18 | extern const float& fdt; 19 | } -------------------------------------------------------------------------------- /Heavy/include/Heavy Utilities.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Heavy Utilities.hpp 5 | Class with conversions or functions that dosen't fit anywhere else, 6 | but are used pretty often 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "Heavy Math.hpp" 13 | 14 | namespace hv { 15 | inline sf::Color Vec3ToColor(const sf::Vector3f& v, sf::Uint8 alpha = 255) { 16 | return sf::Color((sf::Uint8)v.x, (sf::Uint8)v.y, (sf::Uint8)v.z, alpha); 17 | } 18 | 19 | inline sf::Vector3f ColorToVec3(const sf::Color& c) { // Note alpha is striped here 20 | return sf::Vector3f(c.r, c.g, c.b); 21 | } 22 | 23 | inline sf::Vector3f ColorToNormalizedVec3(const sf::Color& c) { // Note alpha is striped here 24 | return sf::Vector3f((float)c.r / 255.0f, (float)c.g / 255.0f, (float)c.b / 255.0f); 25 | } 26 | 27 | inline sf::Glsl::Vec4 ColorToNormalizedVec4(const sf::Color& c) { 28 | return sf::Glsl::Vec4((float)c.r / 255.0f, (float)c.g / 255.0f, (float)c.b / 255.0f, (float)c.a / 255.0f); 29 | } 30 | 31 | inline sf::Color NormalizedVec3ToColor(const sf::Vector3f& v) { // Note alpha is striped here 32 | float r = v.x >= 0.0f ? v.x > 1.0f ? 1.0f : v.x * 255.0f : 0.0f; 33 | float g = v.y >= 0.0f ? v.y > 1.0f ? 1.0f : v.y * 255.0f : 0.0f; 34 | float b = v.z >= 0.0f ? v.z > 1.0f ? 1.0f : v.z * 255.0f : 0.0f; 35 | 36 | return sf::Color((sf::Uint8)r, (sf::Uint8)g, (sf::Uint8)b, (sf::Uint8)255); 37 | } 38 | 39 | static sf::Color HueShift(const sf::Color& color, float shift) { 40 | 41 | sf::Vector3f normalizedColor = ColorToNormalizedVec3(color); 42 | 43 | const sf::Vector3f k(0.57735f, 0.57735f, 0.57735f); 44 | 45 | float cosAngle = cosf(shift); 46 | float sinAngle = sinf(shift); 47 | 48 | sf::Vector3f A = normalizedColor * cosAngle; 49 | sf::Vector3f B = CrossProduct(k, normalizedColor) * sinAngle; 50 | sf::Vector3f C = k * DotProduct(k, normalizedColor) * (1.0f - cosAngle); 51 | 52 | return NormalizedVec3ToColor(A + B + C); 53 | } 54 | 55 | static bool PointIntersect 56 | ( 57 | const sf::Vector2f& point, 58 | const sf::Vector2f& a, const sf::Vector2f& b, 59 | const sf::Vector2f& c, const sf::Vector2f& d 60 | ) 61 | { 62 | //TODO: create 63 | } 64 | } -------------------------------------------------------------------------------- /Heavy/include/Heavy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Runtime.hpp" 4 | #include "Core.hpp" 5 | #include "Asset Manager.hpp" 6 | #include "Heavy Times.hpp" 7 | #include "Timer.hpp" 8 | #include "Input.hpp" 9 | #include "Heavy Math.hpp" -------------------------------------------------------------------------------- /Heavy/include/Ini Parser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace hv { 8 | class IniParser { 9 | public: 10 | IniParser(); 11 | 12 | IniParser(const std::string& path); 13 | 14 | ~IniParser(); 15 | 16 | bool Open(const std::string& path); 17 | bool Close(); 18 | 19 | bool Save(); 20 | void Clear(); 21 | 22 | void Set(const std::string& str , const std::string& section, const std::string& parametr); 23 | void Set(const int& var , const std::string& section, const std::string& parametr); 24 | void Set(const float& var , const std::string& section, const std::string& parametr); 25 | void Set(const sf::Vector2f& vec, const std::string& section, const std::string& parametr); 26 | void Set(const sf::Vector3f& vec, const std::string& section, const std::string& parametr); 27 | void Set(const sf::Color& color, const std::string& section, const std::string& parametr); 28 | 29 | std::string GetStr (const std::string& section, const std::string& parametr) const; 30 | int GetInt (const std::string& section, const std::string& parametr) const; 31 | float GetFloat (const std::string& section, const std::string& parametr) const; 32 | sf::Vector2f GetVec2 (const std::string& section, const std::string& parametr) const; 33 | sf::Vector3f GetVec3 (const std::string& section, const std::string& parametr) const; 34 | sf::Color GetColor (const std::string& section, const std::string& parametr) const; 35 | 36 | private: 37 | // Cashe memory designed not to use linear search in vectors 38 | // Sections with parametrs and values 39 | std::unordered_map> m_Sections; 40 | 41 | // Because of unordered_map behavior we keep order of sections in list 42 | std::list m_SectionOrder; 43 | std::unordered_map> m_ParametrOrder; 44 | 45 | std::fstream m_file; 46 | std::string m_path; 47 | bool m_open = false; 48 | 49 | // Warning handling for given section and parametr I know setting parametr can be made through this but I would have to do warnings other way 50 | const std::string* GetParametr(const std::string& section, const std::string& parametr) const; 51 | 52 | void SetParametr(const std::string& section, const std::string& parametr, const std::string& parsedParametr); 53 | 54 | bool CheckFile() const; 55 | void Load(); 56 | void Parse(std::vector& Lines); 57 | }; 58 | } -------------------------------------------------------------------------------- /Heavy/include/Input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Key Check.hpp 5 | Class checking for user input can read it in not-repeating mode 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace hv { 14 | class Input { 15 | public: 16 | class Keyboard { 17 | public: 18 | // Repeat ~true~ dosen't make function blok checked key 19 | static bool KeyCheck(sf::Keyboard::Key key, bool repeat = false); 20 | }; 21 | 22 | class Mouse { 23 | public: 24 | // Repeat ~true~ dosen't make function blok checked button 25 | static bool KeyCheck(sf::Mouse::Button key, bool repeat = false); 26 | 27 | // Returns mouse position relative to window maped to coords 28 | static sf::Vector2f GetRelativePosition(); 29 | 30 | // Returns mouse position relative to window 31 | static sf::Vector2f GetRelativeCoords(); 32 | 33 | // Returns mouse position NOT RELATIVE TO WINDOW 34 | static sf::Vector2f GetPosition(); 35 | 36 | // Returns mouse position NOT RELATIVE TO WINDOW maped to coords 37 | static sf::Vector2f GetCoords(); 38 | }; 39 | 40 | static void Init(sf::RenderWindow& window); 41 | static void Update(); 42 | static void BlockInput(); 43 | 44 | private: 45 | static std::unordered_map s_Buttons; 46 | static std::unordered_map s_Keys; 47 | 48 | const static sf::RenderWindow* s_window; 49 | }; 50 | } -------------------------------------------------------------------------------- /Heavy/include/Light Renderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Heavy Renderer.hpp" 6 | 7 | namespace std { 8 | template<> struct hash { 9 | std::size_t operator()(const sf::Vector2f& p) const noexcept { 10 | return p(p); 11 | } 12 | }; 13 | } 14 | 15 | namespace hv { 16 | class LightWorld; 17 | struct Edge; 18 | struct Light; 19 | 20 | struct Point 21 | { 22 | Point(sf::Vector2f position, float angle) : 23 | Position(position), 24 | Angle(angle) 25 | { 26 | 27 | } 28 | 29 | sf::Vector2f Position; 30 | float Angle = 0.0f; 31 | }; 32 | } 33 | 34 | namespace hv { 35 | 36 | 37 | class LightRenderer { 38 | public: 39 | LightRenderer(); 40 | ~LightRenderer(); 41 | 42 | void Resize(sf::Vector2u size); 43 | 44 | void DrawLights(Renderer& renderer); 45 | 46 | private: 47 | sf::Shader m_spotShader; 48 | 49 | sf::Shader m_mergeShader; 50 | 51 | sf::RenderTexture m_lightMask; 52 | sf::RenderTexture m_lightMaskBuffer; 53 | 54 | sf::RenderTexture m_shadowMask; 55 | sf::RenderTexture m_shadowMaskBuffer; 56 | 57 | sf::Sprite m_texturer; 58 | 59 | std::vector m_RayPoints; 60 | std::vector m_ShadowVertexArray; 61 | std::unordered_set m_Vertices; 62 | 63 | std::list m_ShadowBox; 64 | 65 | void CreateLightMask(); 66 | void CreateShadowMask(const Light& light); 67 | 68 | void CastRays(sf::Vector2f pos); 69 | 70 | void ResizeTextures(sf::Vector2u size); 71 | void ResizeShaders(sf::Vector2f size); 72 | void ResizeShadowBox(); 73 | 74 | void LoadShaders(); 75 | void InitShadowBox(); 76 | 77 | friend class LightWorld; 78 | }; 79 | } -------------------------------------------------------------------------------- /Heavy/include/Light World.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "Light Renderer.hpp" 11 | 12 | namespace hv { 13 | enum class LightType { Point = 0, Spot }; 14 | 15 | struct Light 16 | { 17 | sf::Vector2f Position; 18 | 19 | float Radius = 0.0f; 20 | float Attenuation = 0.15f; 21 | float LightPower = 1.0f; 22 | 23 | LightType Type; 24 | sf::Color Color = sf::Color::White; 25 | 26 | bool Drawable = true; 27 | 28 | Light(LightType type) : 29 | Type(type) 30 | { 31 | 32 | } 33 | }; 34 | 35 | struct Edge 36 | { 37 | sf::Vector2f Start; 38 | sf::Vector2f End; 39 | }; 40 | } 41 | 42 | namespace hv { 43 | struct PointLight; 44 | struct SpotLight; 45 | } 46 | 47 | namespace hv { 48 | class LightWorld { 49 | public: 50 | void Init(LightRenderer& lightRenderer); 51 | 52 | static LightWorld& Get(); 53 | 54 | // Modifiers 55 | void SetShadowSoftness(float softness); 56 | void SetShadowEnabled(bool enabled); 57 | 58 | void SetLightLevel(float level); 59 | void SetLightEnabled(bool enabled); 60 | 61 | // Accessors 62 | float GetShadowSoftness() const; 63 | bool ShadowsEnabled() const; 64 | 65 | float GetLightLevel() const; 66 | bool LightEnabled() const; 67 | private: 68 | LightWorld(); 69 | ~LightWorld(); 70 | 71 | LightRenderer* m_lightRenderer = nullptr; 72 | 73 | float m_shadowSoftness = 0.5f; 74 | float m_lightLevel = 0.0f; 75 | 76 | bool m_shadowsEnabled = false; 77 | bool m_lightEnabled = false; 78 | 79 | bool m_changed = false; 80 | 81 | std::unordered_set m_Lights; 82 | std::unordered_set m_Edges; 83 | 84 | void DestroyLight(Light* light); 85 | Light* CreateLight(LightType type); 86 | 87 | void DestroyEdge(Edge* edge); 88 | Edge* CreateEdge(sf::Vector2f start = { }, sf::Vector2f end = { }); 89 | 90 | friend struct PointLight; 91 | friend struct SpotLight; 92 | friend struct LightEdge; 93 | 94 | friend class LightRenderer; 95 | 96 | static LightWorld s_instance; 97 | }; 98 | } 99 | -------------------------------------------------------------------------------- /Heavy/include/Light.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Light World.hpp" 5 | 6 | namespace hv { 7 | struct LightEdge 8 | { 9 | LightEdge(); 10 | 11 | LightEdge(sf::Vector2f start, sf::Vector2f end); 12 | 13 | LightEdge(const LightEdge& other); 14 | 15 | ~LightEdge(); 16 | 17 | LightEdge* operator=(const LightEdge& other); 18 | 19 | void Set(sf::Vector2f start, sf::Vector2f end); 20 | 21 | void SetStart(sf::Vector2f start); 22 | void SetEnd(sf::Vector2f end); 23 | 24 | sf::Vector2f GetStart() const; 25 | sf::Vector2f GetEnd() const; 26 | private: 27 | Edge* m_edge = nullptr; 28 | 29 | void CopyEdge(const LightEdge& other); 30 | }; 31 | } 32 | 33 | namespace hv { 34 | struct SpotLight 35 | { 36 | SpotLight(); 37 | 38 | SpotLight(sf::Vector2f pos); 39 | 40 | SpotLight(float radius); 41 | 42 | SpotLight(sf::Vector2f pos, float radius); 43 | 44 | SpotLight(const SpotLight& other); 45 | 46 | ~SpotLight(); 47 | 48 | SpotLight* operator=(const SpotLight& other); 49 | 50 | void SetPosition(sf::Vector2f pos); 51 | void SetRadius(float radius); 52 | void SetAttenuation(float attenuation); 53 | void SetPower(float power); 54 | void SetDrawable(bool drawable); 55 | void SetColor(sf::Color color); 56 | 57 | sf::Vector2f GetPosition() const; 58 | float GetRadius() const; 59 | float GetAttenuation() const; 60 | float GetPower() const; 61 | bool GetDrawable() const; 62 | 63 | private: 64 | Light* m_light = nullptr; 65 | 66 | void CopyLight(const SpotLight& other); 67 | }; 68 | } -------------------------------------------------------------------------------- /Heavy/include/Particle Emitter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Particle Emitter.hpp 5 | Creates and emitts particles 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace hv { 14 | class ParticleEmitter : public sf::Drawable { 15 | public: 16 | ParticleEmitter(); 17 | ~ParticleEmitter(); 18 | 19 | void Update(); 20 | 21 | // Adds particles to emitter should be used close to update function 22 | void AddParticles(); 23 | 24 | // Sets emitter position 25 | void SetPosition(sf::Vector2f pos); 26 | 27 | // Sets direction that particles are flying to 28 | void SetDirection(float x = 0.0f, float y = 0.0f); 29 | 30 | // When one of directionos is set to 0.0 31 | // we add spread to particles 32 | void SetSpread(float spread); 33 | 34 | // Sets particle size 35 | void SetSize(float size); 36 | 37 | // Slows the particle, 1.0 - no torque 38 | void SetTorque(float torque); 39 | 40 | // Time of particle life 41 | void SetLifeTimeRange(float min, float max); 42 | 43 | // Speed the particles move 44 | void SetVelocity(sf::Vector2f velocity); 45 | 46 | // Birth color of particle 47 | void SetBirthColor(sf::Color color); 48 | 49 | // Death color of particle 50 | void SetDeathColor(sf::Color color); 51 | 52 | // Sets max how many particles can be drawen at once 53 | void SetMax(uint32_t max); 54 | 55 | void SetTexture(sf::Texture& texture); 56 | 57 | void SetHueShift(bool var); 58 | private: 59 | struct Particle { 60 | float LifeTime = 0.0f; 61 | float LifeRemaining = 0.0f; 62 | 63 | float Rotation = 0.0f; 64 | 65 | float Size = 0.0f; 66 | float SizeRemaining = 0.0f; 67 | 68 | sf::Vector2f Position; 69 | sf::Vector2f Velocity; 70 | }; 71 | 72 | sf::Vector2f m_pos; 73 | sf::Vector2f m_dir; 74 | 75 | sf::Vector3f m_birthColor = sf::Vector3f(255, 0, 0); 76 | sf::Vector3f m_deathColor = sf::Vector3f(255, 255, 255); 77 | 78 | std::vector m_Vertices; 79 | std::vector m_Particles; 80 | 81 | float m_lifeTimeMin = 1.0f; 82 | float m_lifeTimeMax = 3.0f; 83 | 84 | float m_size = 50.0f; 85 | float m_spread = 0.2f; 86 | float m_torque = 0.988f; 87 | sf::Vector2f m_velocity = sf::Vector2f(100.0f, 100.0f); 88 | 89 | uint32_t m_max = 99; 90 | 91 | sf::Texture* m_texture = nullptr; 92 | 93 | // Color shift 94 | sf::Clock m_shiftClock; 95 | bool m_shift = false; 96 | 97 | void AddQuad(); 98 | void DeleteQuad(size_t index); 99 | void TransformQuad(size_t index, float life); 100 | void SetQuadColor(size_t index, sf::Color color); 101 | 102 | float GetQuadScale(size_t index, float rotation) const; 103 | 104 | void InitParticle(Particle& particle); 105 | 106 | virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const; 107 | }; 108 | } -------------------------------------------------------------------------------- /Heavy/include/Physics World.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "b2_draw.hpp" 6 | 7 | /* 8 | Simple difference between light and physic world is that 9 | Physics world is just abstraction of b2 World class 10 | */ 11 | 12 | namespace hv { 13 | enum class DebugDrawType { Collider = 0, Joint, AABB, MassCenter }; 14 | } 15 | 16 | namespace hv { 17 | class RigidBody; 18 | class Runtime; 19 | struct EdgeCollider; 20 | 21 | class PhysicsWorld { 22 | public: 23 | static PhysicsWorld& Get(); 24 | 25 | template 26 | void EnableDebugDraw(T&&... args) { 27 | uint32_t size = sizeof...(args); 28 | 29 | if (size > 4) 30 | return; 31 | 32 | uint32_t sum = 0; 33 | 34 | DebugDrawType buffer[] = { Refactor(args)... }; 35 | 36 | for (uint32_t i = 0; i < size; i++) 37 | sum += GetB2DrawType(buffer[i]); 38 | 39 | m_debugDraw.SetFlags(sum); 40 | m_debugDrawEnabled = true; 41 | } 42 | 43 | void DisableDebugDraw(); 44 | 45 | private: 46 | PhysicsWorld(); 47 | ~PhysicsWorld(); 48 | 49 | b2World m_world; 50 | 51 | b2DebugDraw m_debugDraw; 52 | bool m_debugDrawEnabled = false; 53 | 54 | template 55 | DebugDrawType Refactor(T const& t) { 56 | DebugDrawType buffer; 57 | 58 | buffer = t; 59 | 60 | return buffer; 61 | } 62 | 63 | void InitDebugDraw(sf::RenderWindow& window); 64 | 65 | uint32_t GetB2DrawType(DebugDrawType type) const; 66 | 67 | friend class RigidBody; 68 | friend class Runtime; 69 | friend struct EdgeCollider; 70 | 71 | static PhysicsWorld s_instance; 72 | }; 73 | } -------------------------------------------------------------------------------- /Heavy/include/Profile Timer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Profile Timer.hpp 5 | High resolution timer used by heavy 6 | to measure time in function calls 7 | */ 8 | 9 | #include 10 | #include "Heavy Debug.hpp" 11 | 12 | namespace hv { 13 | class ProfileTimer { 14 | public: 15 | ProfileTimer(const char* name) 16 | : m_duration(0.0f), m_name(name) 17 | { 18 | m_start = std::chrono::high_resolution_clock::now(); 19 | } 20 | 21 | ~ProfileTimer() 22 | { 23 | m_end = std::chrono::high_resolution_clock::now(); 24 | m_duration = m_end - m_start; 25 | 26 | float ms = m_duration.count() * 1000.0f; 27 | 28 | Color c = ms < 1000.0f ? Color::Green : ms < 5000.0f ? Color::Yellow : Color::Red; 29 | 30 | Debug::Log(c, "[Timer \"", m_name, "\" took ", ms, "ms]\n"); 31 | } 32 | 33 | private: 34 | std::chrono::time_point m_start; 35 | std::chrono::time_point m_end; 36 | 37 | std::chrono::duration m_duration; 38 | const char* m_name; 39 | }; 40 | } -------------------------------------------------------------------------------- /Heavy/include/Random.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Random.hpp 5 | Singleton class featuring simple random number generator 6 | */ 7 | 8 | #include 9 | 10 | namespace hv { 11 | class Random { 12 | public: 13 | static Random& Get(); 14 | 15 | int Int(int min, int max); 16 | float Float(float min, float max); 17 | double Double(double min, double max); 18 | 19 | private: 20 | Random(); 21 | ~Random(); 22 | 23 | std::mt19937 m_randomEngine; 24 | 25 | static Random s_instance; 26 | }; 27 | } -------------------------------------------------------------------------------- /Heavy/include/Rigid Body.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Collider.hpp" 3 | 4 | namespace hv { 5 | enum class BodyType { Static = 0, Kinematic, Dynamic }; 6 | 7 | class RigidBody { 8 | public: 9 | 10 | RigidBody(); 11 | 12 | RigidBody(const RigidBody& other); 13 | 14 | RigidBody(sf::Vector2f pos, BodyType type); 15 | 16 | RigidBody(sf::Vector2f pos, BodyType type, const Collider& collider); 17 | 18 | ~RigidBody(); 19 | 20 | RigidBody* operator=(const RigidBody& other); 21 | 22 | // Modifiers 23 | void SetCollider(const Collider& collider); 24 | void SetPosition(sf::Vector2f position); 25 | void SetType(BodyType type); 26 | void SetGravityScale(float scale); 27 | void SetFixedRotation(bool fixed); 28 | void SetLinearDrag(float drag); 29 | void SetLinearVelocity(sf::Vector2f velocity); 30 | void AddForce(sf::Vector2f velocity); 31 | 32 | // Accessors 33 | sf::Vector2f GetPosition() const; 34 | sf::Vector2f GetLinearVelocity() const; 35 | float GetRotation() const; // Returns rotation in degree 36 | 37 | bool ContainsPoint(sf::Vector2f point) const; 38 | 39 | private: 40 | b2Body* m_body = nullptr; 41 | b2Fixture* m_fixture = nullptr; 42 | Collider* m_collider = nullptr; 43 | 44 | void CopyBody(const RigidBody& other); 45 | }; 46 | } -------------------------------------------------------------------------------- /Heavy/include/Runtime.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Main class used by Heavy to run application 5 | 6 | ~How to use~ 7 | 1. Create class inheriting runtime 8 | 2. Create m_window in it's constructor 9 | 3. Create functions FixedUpdate, Update, Render 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #include "Heavy Times.hpp" 23 | #include "Asset Loader.hpp" 24 | #include "Heavy Renderer.hpp" 25 | #include "Light Renderer.hpp" 26 | 27 | #define USE_MULTITHREAD 1 28 | 29 | namespace hv { 30 | class Runtime { 31 | public: 32 | Runtime(); 33 | virtual ~Runtime(); 34 | 35 | virtual void FixedUpdate() = 0; 36 | virtual void Update() = 0; 37 | virtual void Render() = 0; 38 | 39 | void Run(); 40 | 41 | protected: 42 | sf::RenderWindow m_window; 43 | sf::Event m_event; 44 | 45 | Renderer m_renderer; 46 | 47 | double m_physicsStep = 0.01; 48 | double m_pet = 0.0; // physics elapsed time 49 | 50 | void SetFrameLimit(uint32_t limit); 51 | 52 | private: 53 | sf::Clock m_dtClock; 54 | sf::Clock m_fdtClock; 55 | 56 | uint32_t m_frameLimit = 0; 57 | 58 | LightRenderer m_lightRenderer; 59 | 60 | bool m_focus = true; 61 | 62 | #if USE_MULTITHREAD 63 | std::mutex m_mutex; 64 | std::thread* m_rendererThread = nullptr; 65 | bool m_isRunning = true; 66 | #endif 67 | 68 | void FrameFixedUpdate(); 69 | void FrameUpdate(); 70 | void RendererDraw(); 71 | void HandleEvents(); 72 | void InitRenderer(); 73 | void Delay(); 74 | void GLInit(); // Initializes openGL states 75 | }; 76 | } -------------------------------------------------------------------------------- /Heavy/include/Timer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Timer.hpp 5 | Timer repeats it's given function every period of time 6 | */ 7 | 8 | #include 9 | 10 | namespace hv { 11 | class Timer { 12 | public: 13 | Timer(); 14 | ~Timer(); 15 | 16 | void Update(); 17 | void SetUpdateTime(const float& time); 18 | void SetFunction(std::function fun); 19 | 20 | void Restart(); 21 | 22 | float GetUpdateTime() const; 23 | std::function GetFunction() const; 24 | private: 25 | float m_elapsedTime = 0.0f; 26 | float m_updateTime = 9999.9f; 27 | 28 | std::function m_fun; 29 | }; 30 | } -------------------------------------------------------------------------------- /Heavy/include/b2_draw.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace hv { 7 | class b2DebugDraw : public b2Draw { 8 | public: 9 | b2DebugDraw(); 10 | ~b2DebugDraw(); 11 | 12 | void SetWindow(sf::RenderWindow& window); 13 | private: 14 | sf::RenderWindow* m_window; 15 | 16 | virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); 17 | virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); 18 | virtual void DrawCircle(const b2Vec2& center, float radius, const b2Color& color); 19 | virtual void DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color); 20 | virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); 21 | virtual void DrawTransform(const b2Transform& xf); 22 | virtual void DrawPoint(const b2Vec2& p, float size, const b2Color& color); 23 | virtual void DrawAABB(b2AABB* aabb, const b2Color& color); 24 | }; 25 | } -------------------------------------------------------------------------------- /Heavy/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Heavy" 2 | kind "StaticLib" 3 | language "C++" 4 | cppdialect "C++17" 5 | staticruntime "on" 6 | 7 | targetdir "bin/%{cfg.buildcfg}" 8 | objdir("bin/Obj/%{cfg.buildcfg}") 9 | 10 | pchheader "hvpch.h" 11 | pchsource "core/hvpch.cpp" 12 | 13 | files { 14 | "include/**.h", 15 | "include/**.hpp", 16 | "src/**.cpp", 17 | "*.lua", 18 | "core/hvpch.h", 19 | "core/hvpch.cpp", 20 | 21 | "extlibs/**.cpp", 22 | "extlibs/**.h", 23 | } 24 | 25 | includedirs { 26 | "core", 27 | "include", 28 | "../include", 29 | "../include/Optick" 30 | } 31 | 32 | defines { 33 | "SFML_STATIC" 34 | } 35 | 36 | linkoptions { 37 | "/ignore:4006" 38 | } 39 | 40 | filter "files:extlibs/**.cpp" 41 | flags { "NoPCH" } 42 | 43 | filter "configurations:Debug" 44 | defines { "DEBUG" } 45 | symbols "On" 46 | libdirs { 47 | "../libs/SFML/lib/Debug", 48 | "../libs/SFML/extlibs", 49 | 50 | "../libs/Optick/lib/Debug" 51 | } 52 | 53 | links { 54 | "OptickCore.lib", 55 | "opengl32.lib", 56 | "openal32.lib", 57 | "freetype.lib", 58 | "winmm.lib", 59 | "gdi32.lib", 60 | "flac.lib", 61 | "vorbisenc.lib", 62 | "vorbisfile.lib", 63 | "vorbis.lib", 64 | "ogg.lib", 65 | "ws2_32.lib", 66 | "legacy_stdio_definitions.lib", 67 | "sfml-graphics-s-d.lib", 68 | "sfml-window-s-d.lib", 69 | "sfml-system-s-d.lib", 70 | "sfml-audio-s-d.lib", 71 | "sfml-network-s-d.lib" 72 | } 73 | 74 | filter "configurations:Release" 75 | defines { "NDEBUG" } 76 | optimize "On" 77 | libdirs { 78 | "../libs/SFML/lib/Release", 79 | "../libs/SFML/extlibs", 80 | 81 | "../libs/Optick/lib/Release", 82 | } 83 | 84 | links { 85 | "OptickCore.lib", 86 | "opengl32.lib", 87 | "openal32.lib", 88 | "freetype.lib", 89 | "winmm.lib", 90 | "gdi32.lib", 91 | "flac.lib", 92 | "vorbisenc.lib", 93 | "vorbisfile.lib", 94 | "vorbis.lib", 95 | "ogg.lib", 96 | "ws2_32.lib", 97 | "legacy_stdio_definitions.lib", 98 | "sfml-graphics-s.lib", 99 | "sfml-window-s.lib", 100 | "sfml-system-s.lib", 101 | "sfml-audio-s.lib", 102 | "sfml-network-s.lib" 103 | } 104 | -------------------------------------------------------------------------------- /Heavy/src/Asset Manager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Asset Manager.hpp" 3 | 4 | namespace hv { 5 | //// Shader Lib //// 6 | void ShaderLibrary::Load(std::string name, const char* path) { HV_ASSERT(false); } 7 | 8 | void ShaderLibrary::Load(std::string name, const char* fragmentPath, const char* vertexPath) { 9 | i_Resources[name].loadFromFile( 10 | vertexPath, 11 | fragmentPath 12 | ); 13 | } 14 | 15 | void ShaderLibrary::LoadFromMemory(std::string name, const char* fragment, const char* vertex) { 16 | i_Resources[name].loadFromMemory( 17 | vertex, 18 | fragment 19 | ); 20 | } 21 | 22 | //// Sound Lib //// 23 | void SoundLibrary::Update(const float& soundVol, const float& musicVol) { 24 | for (auto& s : m_Sounds) 25 | s.second.setVolume(soundVol); 26 | 27 | for (auto& m : m_Musics) 28 | m.second.setVolume(musicVol); 29 | } 30 | 31 | void SoundLibrary::ClearSounds() { 32 | for (auto& b : m_Buffers) 33 | delete b; 34 | 35 | m_Buffers.clear(); 36 | } 37 | 38 | void SoundLibrary::ClearMusics() { m_Musics.clear(); } 39 | 40 | // TODO: Check if async SOUND load creates thread error 41 | 42 | // Sound and music volumes are set to 0 by default 43 | void SoundLibrary::LoadSound(std::string name, const char* path) { 44 | // We need SoundBuffer as a pointer so it dosen't change it reference if vector resized 45 | m_Buffers.push_back(new sf::SoundBuffer()); 46 | m_Buffers.back()->loadFromFile(path); 47 | 48 | m_Sounds[name].setBuffer(*m_Buffers.back()); 49 | m_Sounds[name].setVolume(0.0f); 50 | } 51 | 52 | void SoundLibrary::LoadMusic(std::string name, const char* path) { 53 | m_Musics[name].openFromFile(path); 54 | m_Musics[name].setVolume(0.0f); 55 | } 56 | 57 | sf::Sound& SoundLibrary::Sound(const char* name) { return m_Sounds[name]; } 58 | 59 | sf::Music& SoundLibrary::Music(const char* name) { return m_Musics[name]; } 60 | 61 | SoundLibrary::~SoundLibrary() { 62 | for (auto& b : m_Buffers) 63 | delete b; 64 | } 65 | 66 | ShaderLibrary ShaderLibrary::s_instance; 67 | TextureLibrary TextureLibrary::s_instance; 68 | FontLibrary FontLibrary::s_instance; 69 | SoundLibrary SoundLibrary::s_instance; 70 | 71 | } -------------------------------------------------------------------------------- /Heavy/src/Camera.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Camera.hpp" 3 | 4 | #include "Heavy Times.hpp" 5 | #include "Random.hpp" 6 | 7 | namespace hv { 8 | Camera& Camera::Get() { return s_instance; } 9 | 10 | void Camera::Init(sf::RenderWindow* window) { 11 | m_window = window; 12 | 13 | Resize((sf::Vector2f)m_window->getSize()); 14 | } 15 | 16 | void Camera::Update() { 17 | ApplyEffects(); 18 | 19 | m_window->setView(m_view); 20 | } 21 | 22 | void Camera::Shake(float time, int power) { 23 | m_shakeTime = time; 24 | 25 | m_sc.Center = m_view.getCenter(); 26 | 27 | m_sc.CreatePos(power); 28 | } 29 | 30 | void Camera::Move(sf::Vector2f offset) { 31 | m_view.move(offset); 32 | } 33 | 34 | sf::Vector2f Camera::GetCenter() const { 35 | return m_view.getCenter(); 36 | } 37 | 38 | sf::Vector2f Camera::GetSize() const { 39 | return m_view.getSize(); 40 | } 41 | 42 | Camera::Camera() { 43 | 44 | } 45 | 46 | Camera::~Camera() { 47 | 48 | } 49 | 50 | void Camera::ApplyEffects() { 51 | if (m_shakeTime > 0.0f) { 52 | m_shakeTime -= dt; 53 | 54 | if (m_shakeTime <= 0.0f) 55 | m_view.setCenter(m_sc.Center); 56 | else 57 | Shake(); 58 | } 59 | } 60 | 61 | void Camera::Shake() { 62 | m_view.setCenter(m_sc.Center + m_sc.Pos[m_sc.CurrentPos]); 63 | 64 | if (++m_sc.CurrentPos > 6) 65 | m_sc.CurrentPos = 0; 66 | } 67 | 68 | void Camera::Resize(const sf::Vector2f& size) { 69 | m_view.setSize(size); 70 | m_view.setCenter(size / 2.0f); 71 | Projection = Ortho(0.0f, size.x, size.y, 0.0f, -1.0f, 1.0f); 72 | } 73 | 74 | Camera Camera::s_instance; 75 | 76 | // Initializing shake context 77 | void Camera::ShakeContext::CreatePos(const int& power) { 78 | for (int i = 0; i < 6; i++) 79 | Pos[i] = sf::Vector2f((float)Random::Get().Int(-power, power), (float)Random::Get().Int(-power, power)); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Heavy/src/Collider.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Collider.hpp" 3 | 4 | #include "Physics World.hpp" 5 | #include "Core.hpp" 6 | #include 7 | 8 | namespace hv { 9 | Collider::Collider() { 10 | i_fixtureDef.userData.pointer = (uintptr_t)this; 11 | i_fixtureDef.density = 1.0f; 12 | i_fixtureDef.friction = 0.5f; 13 | i_fixtureDef.restitution = 0.0f; 14 | i_fixtureDef.restitutionThreshold = 0.5f; 15 | i_fixtureDef.isSensor = false; 16 | } 17 | 18 | Collider::~Collider() { 19 | 20 | } 21 | 22 | void Collider::SetTriggered(bool triggered) { 23 | i_fixtureDef.isSensor = triggered; 24 | } 25 | } 26 | 27 | namespace hv { 28 | BoxCollider::BoxCollider() { 29 | i_fixtureDef.shape = &m_shape; 30 | 31 | //m_shape.m_radius = 0.005f; 32 | } 33 | 34 | BoxCollider::BoxCollider(sf::Vector2f size) { 35 | size /= 2.0f; 36 | size /= Constants::PPM; 37 | 38 | m_shape.SetAsBox(size.x, size.y); 39 | 40 | i_fixtureDef.shape = &m_shape; 41 | } 42 | 43 | BoxCollider::~BoxCollider() { 44 | 45 | } 46 | 47 | void BoxCollider::SetSize(sf::Vector2f size) { 48 | size /= 2.0f; 49 | size /= Constants::PPM; 50 | 51 | m_shape.SetAsBox(size.x, size.y); 52 | } 53 | } 54 | 55 | namespace hv { 56 | CircleCollider::CircleCollider() { 57 | i_fixtureDef.shape = &m_shape; 58 | } 59 | 60 | CircleCollider::CircleCollider(float radius) { 61 | radius /= Constants::PPM; 62 | 63 | m_shape.m_radius = radius; 64 | 65 | i_fixtureDef.shape = &m_shape; 66 | } 67 | 68 | CircleCollider::~CircleCollider() { 69 | 70 | } 71 | 72 | void CircleCollider::SetRadius(float radius) { 73 | radius /= Constants::PPM; 74 | 75 | m_shape.m_radius = radius; 76 | } 77 | } 78 | 79 | namespace hv { 80 | //TODO: finish 81 | EdgeCollider::EdgeCollider() { 82 | b2BodyDef bodyDef; 83 | 84 | m_body = PhysicsWorld::Get().m_world.CreateBody(&bodyDef); 85 | 86 | i_fixtureDef.shape = &m_shape; 87 | i_fixtureDef.density = 0.0f; 88 | i_fixtureDef.friction = 0.5f; 89 | } 90 | 91 | EdgeCollider::~EdgeCollider() { 92 | PhysicsWorld::Get().m_world.DestroyBody(m_body); 93 | } 94 | 95 | void EdgeCollider::AddPoints(sf::Vector2f start, sf::Vector2f end) { 96 | m_shape.SetTwoSided(start / Constants::PPM, end / Constants::PPM); 97 | 98 | m_body->CreateFixture(&i_fixtureDef); 99 | } 100 | } 101 | 102 | namespace hv { 103 | void ContactListener::BeginContact(b2Contact* contact) { 104 | if(contact->GetFixtureA()->IsSensor()) 105 | ((Collider*)contact->GetFixtureA()->GetUserData().pointer)->Function(); 106 | } 107 | 108 | void ContactListener::EndContact(b2Contact* contact) { 109 | 110 | } 111 | } -------------------------------------------------------------------------------- /Heavy/src/Event Dispatcher.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Event Dispatcher.hpp" 3 | 4 | namespace hv { 5 | bool* EventDispatcher::s_focus; 6 | std::unordered_map EventDispatcher::s_events; 7 | 8 | void EventDispatcher::Init(bool& focus) { 9 | s_focus = &focus; 10 | } 11 | 12 | void EventDispatcher::DispatchEvent(const sf::Event& event) { 13 | s_events.insert(std::make_pair(event.type, event)); 14 | } 15 | 16 | bool EventDispatcher::CheckFor(sf::Event::EventType type) { 17 | return s_events.find(type) != s_events.end(); 18 | } 19 | 20 | sf::Event EventDispatcher::GetEvent(sf::Event::EventType type) { 21 | return s_events[type]; 22 | } 23 | 24 | void EventDispatcher::Clear() { 25 | s_events.clear(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Heavy/src/Fixed Clock.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Fixed Clock.hpp" 3 | 4 | // Little bit of code here is taken from 5 | // https://github.com/Bromeon/Thor/blob/master/src/StopWatch.cpp 6 | 7 | namespace hv { 8 | FixedClock::FixedClock(bool start) { 9 | if (start) 10 | Start(); 11 | } 12 | 13 | FixedClock::~FixedClock() { 14 | 15 | } 16 | 17 | void FixedClock::Start() { 18 | if (!m_running) { 19 | m_running = true; 20 | m_clock.restart(); 21 | } 22 | } 23 | 24 | void FixedClock::Stop() { 25 | if (m_running) { 26 | m_running = false; 27 | m_stoppedTime = m_clock.getElapsedTime(); 28 | } 29 | } 30 | 31 | void FixedClock::Restart() { 32 | m_stoppedTime = sf::Time::Zero; 33 | m_running = false; 34 | Start(); 35 | } 36 | 37 | sf::Time FixedClock::GetElapsedTime() const { 38 | if (m_running) 39 | return m_stoppedTime + m_clock.getElapsedTime(); 40 | 41 | return m_stoppedTime; 42 | } 43 | } -------------------------------------------------------------------------------- /Heavy/src/Glow Effect.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Glow Effect.hpp" 3 | 4 | #include "Heavy Utilities.hpp" 5 | 6 | namespace hv { 7 | GlowEffect::GlowEffect() { 8 | if (!s_shader) { 9 | //TODO: powiedz ze to potrzebne ten leak 10 | s_shader = new sf::Shader(); 11 | s_shader->loadFromMemory(ShaderSource::Vertex, ShaderSource::Fragment); 12 | } 13 | 14 | // Because of triangles 15 | m_vertices[0].texCoords = sf::Vector2f(0.0f, 0.0f); 16 | m_vertices[1].texCoords = sf::Vector2f(1.0f, 0.0f); 17 | m_vertices[2].texCoords = sf::Vector2f(1.0f, 1.0f); 18 | 19 | m_vertices[3].texCoords = sf::Vector2f(0.0f, 0.0f); 20 | m_vertices[4].texCoords = sf::Vector2f(0.0f, 1.0f); 21 | m_vertices[5].texCoords = sf::Vector2f(1.0f, 1.0f); 22 | } 23 | 24 | GlowEffect::~GlowEffect() { 25 | 26 | } 27 | 28 | void GlowEffect::SetRadius(float radius) { 29 | m_radius = radius; 30 | 31 | TranslateVertices(); 32 | } 33 | 34 | void GlowEffect::SetPosition(sf::Vector2f pos) { 35 | m_position = pos; 36 | 37 | TranslateVertices(); 38 | } 39 | 40 | void GlowEffect::TranslateVertices() { 41 | m_vertices[0].position = sf::Vector2f(m_position.x - m_radius, m_position.y - m_radius); 42 | m_vertices[1].position = sf::Vector2f(m_position.x + m_radius, m_position.y - m_radius); 43 | m_vertices[2].position = sf::Vector2f(m_position.x + m_radius, m_position.y + m_radius); 44 | 45 | m_vertices[3].position = sf::Vector2f(m_position.x - m_radius, m_position.y - m_radius); 46 | m_vertices[4].position = sf::Vector2f(m_position.x - m_radius, m_position.y + m_radius); 47 | m_vertices[5].position = sf::Vector2f(m_position.x + m_radius, m_position.y + m_radius); 48 | } 49 | 50 | void GlowEffect::draw(sf::RenderTarget& target, sf::RenderStates states) const { 51 | s_shader->setUniform("u_color", ColorToNormalizedVec4(Color)); 52 | 53 | states.shader = s_shader; 54 | 55 | target.draw(m_vertices, 6, sf::Triangles, states); 56 | } 57 | 58 | const std::string GlowEffect::ShaderSource::Vertex = R"( 59 | varying vec2 uv; 60 | void main() 61 | { 62 | uv = gl_TextureMatrix[0] * gl_MultiTexCoord0 * 2.0 - 1.0; 63 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 64 | }; 65 | )"; 66 | 67 | const std::string GlowEffect::ShaderSource::Fragment = R"( 68 | #version 330 core 69 | 70 | const float alphaPower = 2.0; 71 | 72 | layout(location = 0) out vec4 color; 73 | 74 | uniform vec4 u_color; 75 | 76 | in vec2 uv; 77 | void main() 78 | { 79 | float distance = 1.0 - length(uv); 80 | 81 | if(distance < -0.05) 82 | discard; 83 | 84 | color = vec4(u_color.rgb, pow(distance, alphaPower) * u_color.a); 85 | }; 86 | )"; 87 | 88 | sf::Shader* GlowEffect::s_shader = nullptr; 89 | } -------------------------------------------------------------------------------- /Heavy/src/Heavy Renderer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Heavy Renderer.hpp" 3 | 4 | namespace hv { 5 | Renderer::Renderer() { 6 | 7 | } 8 | 9 | Renderer::~Renderer() { 10 | 11 | } 12 | 13 | void Renderer::Resize(sf::Vector2u size) { 14 | m_frame::create(size.x, size.y); 15 | m_frame::clear(); 16 | m_frame::display(); 17 | } 18 | 19 | void Renderer::clear() { 20 | m_frame::clear(ClearColor); 21 | } 22 | 23 | const sf::Sprite& Renderer::GetFrame() { 24 | m_frameSprite.setTexture(m_frame::getTexture()); 25 | return m_frameSprite; 26 | } 27 | } -------------------------------------------------------------------------------- /Heavy/src/Heavy Times.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Heavy Times.hpp" 3 | 4 | namespace hv { 5 | Times Times::Instance; 6 | 7 | const float& dt = Times::Instance.DT; 8 | const float& fdt = Times::Instance.FDT; 9 | } -------------------------------------------------------------------------------- /Heavy/src/Input.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Input.hpp" 3 | 4 | namespace hv { 5 | bool Input::Keyboard::KeyCheck(sf::Keyboard::Key key, bool repeat) { 6 | bool pressed = sf::Keyboard::isKeyPressed(key); 7 | 8 | if (repeat) 9 | return pressed; 10 | 11 | if (!s_Keys[key] && pressed) { 12 | s_Keys[key] = true; 13 | return true; 14 | } 15 | 16 | return false; 17 | } 18 | 19 | bool Input::Mouse::KeyCheck(sf::Mouse::Button key, bool repeat) { 20 | bool pressed = sf::Mouse::isButtonPressed(key); 21 | 22 | if (repeat) 23 | return pressed; 24 | 25 | if (!s_Buttons[key] && pressed) { 26 | s_Buttons[key] = true; 27 | return true; 28 | } 29 | 30 | return false; 31 | } 32 | 33 | sf::Vector2f Input::Mouse::GetRelativePosition() { 34 | if (!s_window->getSystemHandle()) 35 | return { }; 36 | 37 | return sf::Vector2f(sf::Mouse::getPosition(*s_window)); 38 | } 39 | 40 | sf::Vector2f Input::Mouse::GetRelativeCoords() { 41 | if (!s_window->getSystemHandle()) 42 | return { }; 43 | 44 | return s_window->mapPixelToCoords(sf::Mouse::getPosition(*s_window)); 45 | } 46 | 47 | sf::Vector2f Input::Mouse::GetPosition() { 48 | if (!s_window->getSystemHandle()) 49 | return { }; 50 | 51 | return (sf::Vector2f)sf::Mouse::getPosition(); 52 | } 53 | 54 | sf::Vector2f Input::Mouse::GetCoords() { 55 | if (!s_window->getSystemHandle()) 56 | return { }; 57 | 58 | return s_window->mapPixelToCoords(sf::Mouse::getPosition()); 59 | } 60 | 61 | void Input::Init(sf::RenderWindow& window) { 62 | s_window = &window; 63 | 64 | // Keyboard init 65 | for (int i = -1; i < sf::Keyboard::KeyCount; i++) 66 | s_Keys[(sf::Keyboard::Key)i] = false; 67 | 68 | // Mouse init 69 | for (int i = 0; i < sf::Mouse::ButtonCount; i++) 70 | s_Buttons[(sf::Mouse::Button)i] = false; 71 | } 72 | 73 | void Input::Update() { 74 | for (auto& key : s_Keys) 75 | if (!sf::Keyboard::isKeyPressed(key.first)) 76 | key.second = false; 77 | 78 | for (auto& button : s_Buttons) 79 | if(!sf::Mouse::isButtonPressed(button.first)) 80 | button.second = false; 81 | } 82 | 83 | void Input::BlockInput() { 84 | for (auto& key : s_Keys) 85 | key.second = true; 86 | 87 | for (auto& button : s_Buttons) 88 | button.second = true; 89 | } 90 | 91 | std::unordered_map Input::s_Keys; 92 | std::unordered_map Input::s_Buttons; 93 | const sf::RenderWindow* Input::s_window; 94 | } 95 | -------------------------------------------------------------------------------- /Heavy/src/Light World.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Light World.hpp" 3 | 4 | #include "Camera.hpp" 5 | #include "Heavy Utilities.hpp" 6 | 7 | #include "Input.hpp" 8 | 9 | namespace hv { 10 | LightWorld LightWorld::s_instance; 11 | 12 | LightWorld::LightWorld() { 13 | m_Lights.reserve(2048); 14 | 15 | m_Edges.reserve(2048); 16 | } 17 | 18 | LightWorld::~LightWorld() { 19 | 20 | } 21 | 22 | void LightWorld::Init(LightRenderer& lightRenderer) { 23 | m_lightRenderer = &lightRenderer; 24 | } 25 | 26 | LightWorld& LightWorld::Get() { 27 | return s_instance; 28 | } 29 | 30 | void LightWorld::SetShadowSoftness(float softness) { 31 | m_shadowSoftness = softness; 32 | } 33 | 34 | void LightWorld::SetShadowEnabled(bool enabled) { 35 | m_shadowsEnabled = enabled; 36 | } 37 | 38 | void LightWorld::SetLightLevel(float level) { 39 | m_lightLevel = level; 40 | 41 | if (m_lightRenderer) 42 | m_lightRenderer->m_mergeShader.setUniform("u_level", m_lightLevel < 0.0f ? 0.0f : m_lightLevel); 43 | } 44 | 45 | void LightWorld::SetLightEnabled(bool enabled) { 46 | m_lightEnabled = enabled; 47 | } 48 | 49 | float LightWorld::GetShadowSoftness() const { 50 | return m_shadowSoftness; 51 | } 52 | 53 | bool LightWorld::ShadowsEnabled() const { 54 | return m_shadowsEnabled; 55 | } 56 | 57 | float LightWorld::GetLightLevel() const { 58 | return m_lightLevel; 59 | } 60 | 61 | bool LightWorld::LightEnabled() const { 62 | return m_lightEnabled; 63 | } 64 | 65 | void LightWorld::DestroyLight(Light* light) { 66 | m_Lights.erase(light); 67 | 68 | delete light; 69 | } 70 | 71 | Light* LightWorld::CreateLight(LightType type) { 72 | Light* buffer = new Light(type); 73 | 74 | m_Lights.emplace(buffer); 75 | 76 | return buffer; 77 | } 78 | 79 | void LightWorld::DestroyEdge(Edge* edge) { 80 | m_Edges.erase(edge); 81 | 82 | delete edge; 83 | } 84 | 85 | Edge* LightWorld::CreateEdge(sf::Vector2f start, sf::Vector2f end) { 86 | Edge* buffer = new Edge({ start, end }); 87 | 88 | m_Edges.emplace(buffer); 89 | 90 | return buffer; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Heavy/src/Physics World.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Physics World.hpp" 3 | 4 | #include "Collider.hpp" 5 | #include "b2_draw.hpp" 6 | 7 | namespace hv { 8 | PhysicsWorld& PhysicsWorld::Get() { return s_instance; } 9 | 10 | void PhysicsWorld::InitDebugDraw(sf::RenderWindow& window) { 11 | m_debugDraw.SetWindow(window); 12 | 13 | m_world.SetDebugDraw(&m_debugDraw); 14 | } 15 | 16 | uint32_t PhysicsWorld::GetB2DrawType(DebugDrawType type) const { 17 | switch (type) { 18 | 19 | case hv::DebugDrawType::Collider: 20 | return b2Draw::e_shapeBit; 21 | 22 | case hv::DebugDrawType::Joint: 23 | return b2Draw::e_jointBit; 24 | 25 | case hv::DebugDrawType::AABB: 26 | return b2Draw::e_aabbBit; 27 | 28 | case hv::DebugDrawType::MassCenter: 29 | return b2Draw::e_centerOfMassBit; 30 | } 31 | 32 | return 0; 33 | } 34 | 35 | static ContactListener Listener; 36 | 37 | void PhysicsWorld::DisableDebugDraw() { 38 | m_debugDraw.SetFlags(0); 39 | 40 | m_debugDrawEnabled = false; 41 | } 42 | 43 | PhysicsWorld::PhysicsWorld() : 44 | m_world(sf::Vector2f(0.0f, 10.0f)) 45 | { 46 | m_world.SetContactListener(&Listener); 47 | } 48 | 49 | PhysicsWorld::~PhysicsWorld() { 50 | 51 | } 52 | 53 | PhysicsWorld PhysicsWorld::s_instance; 54 | } -------------------------------------------------------------------------------- /Heavy/src/Random.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Random.hpp" 3 | 4 | namespace hv { 5 | Random& Random::Get() { return s_instance; } 6 | 7 | int Random::Int(int min, int max) { return std::uniform_int_distribution(min, max)(m_randomEngine); } 8 | 9 | float Random::Float(float min, float max) { return std::uniform_real_distribution(min, max)(m_randomEngine); } 10 | 11 | double Random::Double(double min, double max) { return std::uniform_real_distribution(min, max)(m_randomEngine); } 12 | 13 | Random::Random() { 14 | m_randomEngine.seed(std::random_device()()); 15 | } 16 | 17 | Random::~Random() { 18 | 19 | } 20 | 21 | Random Random::s_instance; 22 | } -------------------------------------------------------------------------------- /Heavy/src/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Timer.hpp" 3 | 4 | #include "Heavy Times.hpp" 5 | 6 | namespace hv { 7 | Timer::Timer() { 8 | 9 | } 10 | 11 | Timer::~Timer() { 12 | 13 | } 14 | 15 | void Timer::Update() { 16 | m_elapsedTime += hv::dt; 17 | while (m_elapsedTime >= m_updateTime) { 18 | 19 | m_fun(); 20 | 21 | m_elapsedTime -= m_updateTime; 22 | } 23 | } 24 | 25 | void Timer::SetUpdateTime(const float& time) { m_updateTime = time; } 26 | 27 | void Timer::SetFunction(std::function fun) { m_fun = fun; } 28 | 29 | void Timer::Restart() { m_elapsedTime = 0.0f; } 30 | 31 | float Timer::GetUpdateTime() const { return m_updateTime; } 32 | 33 | std::function Timer::GetFunction() const { return m_fun; } 34 | } -------------------------------------------------------------------------------- /Images/heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Images/heavy.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Heavy Engine](https://github.com/xSnapi/Heavy/blob/master/Images/heavy.png?raw=true) 2 | 3 | # Heavy 4 | ## Engine for SFML games 5 | The main goal of Heavy is to make it as close to SFML syntax as possible. For example creating rigid body is easy as ```hv::RigidBody rb;``` and thats really it. 6 | *** 7 | 8 | ## Heavy uses: 9 | 10 | ![alt text](https://www.sfml-dev.org/images/logo.png "SFML") 11 | ![alt text](https://box2d.org/images/logo.svg "box2D") 12 | ![alt text](https://github.com/bombomby/optick/blob/master/samples/UnrealEnginePlugin/Resources/Icon128.png?raw=true "OPTICK") 13 | 14 | 15 | ### [SFML](https://github.com/SFML/SFML) | [Box2D](https://github.com/erincatto/box2d) | [Optick](https://github.com/bombomby/optick) | [ImGui](https://github.com/ocornut/imgui) 16 | 17 | 18 |
19 |
20 | 21 | ## Why "Heavy" tho? 22 | As inexperienced programmer I thought it will come up clumsy and inefficient so I called it heavy. 23 | In the opposite it come up pretty well (beside few things). 24 | 25 | 26 | ## Heavy Features: 27 | 28 | ### Main Features: 29 | * **Uses separate thread for drawing resulting in higher performance** 30 | * **Separate update and fixed update allows for better physics simulations** 31 | * **Custom renderer makes lights and shadow possible** 32 | * **Delta time and fixed delta time accessible from everywhere** 33 | * **Well abstracted [box2d](https://github.com/erincatto/box2d) made easy to use for everyone** 34 | * **Many profiler macros integrated from [Optick](https://github.com/bombomby/optick)** 35 | * **Lights and shadows easy in use and control** 36 | * **Asynchronous asset load** 37 | 38 | ### Classes and their use 39 | * **Runtime** - main class, runs the application 40 | * **Asset Manager** - used to store textures etc. 41 | * **Asset Loader** - used to asynchronously load assets 42 | * **Camera** - overall camera controll features functions as shake etc. 43 | * **Colliders** - different colliders for convex shapes featuring drawing 44 | * **Event Dispatcher** - allows you to control events from everywhere 45 | * **Fixed Clock** - featuring start and stop 46 | * **Heavy Math and Utilities** - different math and conversion functions 47 | * **Key Check** - checks user input can work in not repeat mode 48 | * **Particle Emitter** - creating and controlling squared particles 49 | * **Profile Timer** - used to time function 50 | * **Random** - simple random numbers generator 51 | * **Timer** - repeats it's given function every period of time 52 | * **Animator** - handles sprite sheet animations 53 | * 54 | -------------------------------------------------------------------------------- /Sandbox/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "Application.hpp" 2 | 3 | #include "Asset Loader.hpp" 4 | #include "Heavy ImGui.hpp" 5 | 6 | Application::Application() { 7 | InitWindow(); 8 | InitAssets(); 9 | 10 | m_campfire.FrameWidth = 500; 11 | m_campfire.FrameHeight = 500; 12 | m_campfire.Speed = 0.25f; 13 | m_campfire.Reversed = false; 14 | 15 | m_campfire.Create(10, 1, 0, &m_campfireSprite, &hv::TextureLibrary::Get().Res("campfire")); 16 | } 17 | 18 | Application::~Application() { 19 | 20 | } 21 | 22 | void Application::FixedUpdate() { 23 | 24 | } 25 | 26 | void Application::Update() { 27 | m_animator.Play(m_campfire); 28 | 29 | ImGui::Begin("Window"); 30 | m_campfire.GetImGuiInfo("campfire"); 31 | ImGui::End(); 32 | 33 | if (hv::Input::Keyboard::KeyCheck(sf::Keyboard::Space)) 34 | m_campfire.Reversed = !m_campfire.Reversed; 35 | } 36 | 37 | void Application::Render() { 38 | m_renderer.draw(sf::Sprite(hv::TextureLibrary::Get().Res("background"))); 39 | m_renderer.draw(m_campfireSprite); 40 | } 41 | 42 | void Application::InitAssets() { 43 | hv::AssetLoader::Get().AddResource("background", "res/bricks.png", hv::AssetType::Texture); 44 | hv::AssetLoader::Get().AddResource("campfire", "res/numeras.png", hv::AssetType::Texture); 45 | hv::AssetLoader::Get().Sync(); 46 | } 47 | 48 | void Application::InitWindow() { 49 | sf::VideoMode videoMode; 50 | 51 | videoMode.width = 800; 52 | videoMode.height = 800; 53 | 54 | sf::ContextSettings contextSettings; 55 | //contextSettings.antialiasingLevel = 8; 56 | 57 | m_window.create(videoMode, "Sandbox", sf::Style::Close, contextSettings); 58 | 59 | SetFrameLimit(144); 60 | } 61 | -------------------------------------------------------------------------------- /Sandbox/Application.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | #include "Animator.hpp" 7 | 8 | class Application : public hv::Runtime { 9 | public: 10 | Application(); 11 | ~Application(); 12 | 13 | private: 14 | virtual void FixedUpdate(); 15 | virtual void Update(); 16 | virtual void Render(); 17 | 18 | void InitAssets(); 19 | void InitWindow(); 20 | 21 | hv::Animation m_campfire; 22 | hv::Animator m_animator; 23 | 24 | sf::Sprite m_campfireSprite; 25 | }; 26 | -------------------------------------------------------------------------------- /Sandbox/OptickCore.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/OptickCore.dll -------------------------------------------------------------------------------- /Sandbox/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=60,60 3 | Size=400,400 4 | Collapsed=0 5 | 6 | [Window][Window] 7 | Pos=501,28 8 | Size=279,399 9 | Collapsed=0 10 | 11 | -------------------------------------------------------------------------------- /Sandbox/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Application.hpp" 2 | 3 | int main() { 4 | Application application; 5 | 6 | application.Run(); 7 | 8 | return EXIT_SUCCESS; 9 | } -------------------------------------------------------------------------------- /Sandbox/openal32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/openal32.dll -------------------------------------------------------------------------------- /Sandbox/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Sandbox" 2 | kind "ConsoleApp" 3 | language "C++" 4 | cppdialect "C++17" 5 | staticruntime "on" 6 | 7 | targetdir "bin/%{cfg.buildcfg}" 8 | objdir("bin/Obj/%{cfg.buildcfg}") 9 | 10 | files { 11 | "**.h", 12 | "**.hpp", 13 | "**.cpp", 14 | "*.lua", 15 | "*.dll" 16 | } 17 | 18 | includedirs { 19 | "../Heavy/include", 20 | "../include", 21 | } 22 | 23 | links { 24 | "Heavy" 25 | } 26 | 27 | defines { 28 | "SFML_STATIC" 29 | } 30 | 31 | filter "configurations:Debug" 32 | defines { "DEBUG" } 33 | symbols "On" 34 | 35 | filter "configurations:Release" 36 | defines { "NDEBUG" } 37 | optimize "On" 38 | -------------------------------------------------------------------------------- /Sandbox/res/bricks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/bricks.png -------------------------------------------------------------------------------- /Sandbox/res/circle_fragment.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | void main() { 4 | float distance = 1.0 - length(uv); 5 | 6 | if (distance > 0.0) 7 | distance = 1.0; 8 | 9 | gl_FragColor = vec4(1.0, 0.0, 0.0, 0.45) * distance; 10 | } -------------------------------------------------------------------------------- /Sandbox/res/circle_vertex.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | void main() { 4 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 5 | 6 | uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0) * 2.0 - 1.0; 7 | 8 | gl_FrontColor = gl_Color; 9 | } -------------------------------------------------------------------------------- /Sandbox/res/file.ini: -------------------------------------------------------------------------------- 1 | [sus] 2 | str=1 3 | amogs=5 4 | vent=3 5 | sisssi=1023 6 | abisib=5 7 | 8 | [amogus] 9 | str=10 10 | amogs=5 11 | vent=3 12 | sisssi=1023 13 | abisib=5 14 | 15 | [aventus] 16 | str=penis 17 | amogs=5 18 | vent=3 19 | sisssi=1023 20 | abisib=5 21 | -------------------------------------------------------------------------------- /Sandbox/res/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/font.ttf -------------------------------------------------------------------------------- /Sandbox/res/gradientFrag.shader: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) out vec4 color; 4 | 5 | uniform float u_time; 6 | 7 | vec3 hueShift(vec3 color) { 8 | vec3 k = vec3(0.57735); 9 | float cosAngle = cos(u_time); 10 | float sinAngle = sin(u_time); 11 | 12 | vec3 A = color * cosAngle; 13 | vec3 B = cross(k, color) * sinAngle; 14 | vec3 C = k * dot(k, color) * (1.0 - cosAngle); 15 | 16 | return vec3(A); 17 | } 18 | 19 | in vec3 u_color; 20 | void main() 21 | { 22 | vec3 Color = hueShift(vec3(1.0, 0.0, 0.0)); 23 | 24 | //color = vec4(Color, 1.0); 25 | color = vec4(u_color, 1.0); 26 | }; -------------------------------------------------------------------------------- /Sandbox/res/gradientVert.shader: -------------------------------------------------------------------------------- 1 | varying vec3 u_color; 2 | uniform mat4 Projection; 3 | void main() 4 | { 5 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 6 | u_color = gl_Color; 7 | }; -------------------------------------------------------------------------------- /Sandbox/res/heart_fragment.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | void main() { 4 | vec3 col = vec3(0.0); 5 | 6 | uv.x *= 0.7; 7 | uv.y += sqrt(abs(uv.x)) * 0.5; 8 | float d = length(uv); 9 | 10 | float c = smoothstep(0.6, 0.56, d); 11 | 12 | col = vec3(c); 13 | 14 | if (c < 1.0) 15 | discard; 16 | 17 | gl_FragColor = vec4(1.0, 0.0, 0.0, 0.75) * vec4(col, 1.0); 18 | } 19 | -------------------------------------------------------------------------------- /Sandbox/res/heart_vertex.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | void main() { 4 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 5 | 6 | uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0) * 2.0 - 1.0; 7 | 8 | gl_FrontColor = gl_Color; 9 | } -------------------------------------------------------------------------------- /Sandbox/res/hv_fragment.shader: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) out vec4 color; 4 | 5 | in vec4 u_color; 6 | 7 | void main() 8 | { 9 | color = u_color; 10 | }; -------------------------------------------------------------------------------- /Sandbox/res/hv_vertex.shader: -------------------------------------------------------------------------------- 1 | varying vec4 u_color; 2 | 3 | uniform mat4 Projection; 4 | void main() 5 | { 6 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 7 | 8 | u_color = gl_Color; 9 | }; -------------------------------------------------------------------------------- /Sandbox/res/kuba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/kuba.png -------------------------------------------------------------------------------- /Sandbox/res/light_fragment.shader: -------------------------------------------------------------------------------- 1 | varying vec2 st; 2 | 3 | uniform sampler2D texture; 4 | 5 | uniform vec2 u_resolution; 6 | uniform vec2 u_positions[99]; 7 | uniform float u_radius[99]; 8 | uniform float u_backLight; 9 | uniform int u_size; 10 | 11 | vec3 Circle(vec2 position, vec3 color, float radius) { 12 | float circle = sqrt(pow(position.x, 2.0) + pow(position.y, 2.0)); 13 | circle = smoothstep(radius, radius + 0.15, 1.0 - circle); 14 | 15 | return (color - vec3(u_backLight)) * circle; 16 | } 17 | 18 | void main() { 19 | vec2 uv = gl_FragCoord.xy / u_resolution; 20 | 21 | vec4 pixel = texture2D(texture, st.xy); 22 | 23 | vec3 canvas = vec3(u_backLight); 24 | 25 | 26 | for (int i = 0; i < u_size; i++) { 27 | vec3 circle = Circle(uv - (u_positions[i] / u_resolution), vec3(1.0, 1.0, 1.0), 1.0 - (u_radius[i] / u_resolution.x)); 28 | 29 | canvas += circle; 30 | } 31 | 32 | gl_FragColor = pixel * vec4(canvas, 1.0); 33 | }; -------------------------------------------------------------------------------- /Sandbox/res/light_vertex.shader: -------------------------------------------------------------------------------- 1 | varying vec2 st; 2 | 3 | void main() { 4 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 5 | 6 | st = gl_TextureMatrix[0] * gl_MultiTexCoord0; 7 | 8 | gl_FrontColor = gl_Color; 9 | } -------------------------------------------------------------------------------- /Sandbox/res/music.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/music.ogg -------------------------------------------------------------------------------- /Sandbox/res/numeras.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/numeras.png -------------------------------------------------------------------------------- /Sandbox/res/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/sky.png -------------------------------------------------------------------------------- /Sandbox/res/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/smoke.png -------------------------------------------------------------------------------- /Sandbox/res/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/snow.png -------------------------------------------------------------------------------- /Sandbox/res/spritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/spritesheet.png -------------------------------------------------------------------------------- /Sandbox/res/spritesheetv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/spritesheetv.png -------------------------------------------------------------------------------- /Sandbox/res/texture_fragment.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | uniform sampler2D texture; 4 | 5 | void main() { 6 | vec4 pixel = texture2D(texture, uv.xy); 7 | 8 | gl_FragColor = pixel; 9 | }; -------------------------------------------------------------------------------- /Sandbox/res/texture_vertex.shader: -------------------------------------------------------------------------------- 1 | varying vec2 uv; 2 | 3 | void main() { 4 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 5 | 6 | uv = gl_TextureMatrix[0] * gl_MultiTexCoord0; 7 | 8 | gl_FrontColor = gl_Color; 9 | } -------------------------------------------------------------------------------- /Sandbox/res/tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/Sandbox/res/tree.png -------------------------------------------------------------------------------- /Sandbox/temp/default.vert: -------------------------------------------------------------------------------- 1 | varying vec2 i_tex; 2 | 3 | void main() { 4 | i_tex = gl_TextureMatrix[0] * gl_MultiTexCoord0; 5 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 6 | } -------------------------------------------------------------------------------- /Sandbox/temp/lightShadow.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | precision lowp float; 4 | 5 | layout(location = 0) out vec4 o_color; 6 | 7 | in vec2 i_tex; 8 | 9 | uniform sampler2D texture; 10 | uniform sampler2D u_shadows; 11 | 12 | void main() { 13 | 14 | vec4 pixel = texture2D(texture, i_tex); 15 | vec4 shadowPixel = texture2D(u_shadows, i_tex); 16 | 17 | o_color = pixel * shadowPixel; 18 | } -------------------------------------------------------------------------------- /Sandbox/temp/merge.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision lowp float; 4 | 5 | layout(location = 0) out vec4 o_color; 6 | 7 | in vec2 i_tex; 8 | 9 | uniform sampler2D texture; 10 | uniform sampler2D u_mergeTx; 11 | 12 | uniform float u_level; 13 | 14 | void main() { 15 | vec4 pixel = texture2D(texture, i_tex); 16 | 17 | vec4 lightPixel = texture2D(u_mergeTx, i_tex); 18 | 19 | vec4 light = vec4(1.0 - lightPixel.x , 1.0 - lightPixel.y, 1.0 - lightPixel.z, 1.0) + u_level; 20 | 21 | light = clamp(light, 0.0, 1.0); 22 | 23 | o_color = pixel * light; 24 | } -------------------------------------------------------------------------------- /Sandbox/temp/spot.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | precision lowp float; 4 | 5 | layout(location = 0) out vec4 o_color; 6 | 7 | in vec2 i_tex; 8 | 9 | uniform sampler2D u_shadow; 10 | uniform sampler2D texture; 11 | 12 | uniform vec2 u_resolution; 13 | uniform vec2 u_position; 14 | uniform vec3 u_color; 15 | uniform float u_radius; 16 | uniform float u_attenuation; 17 | uniform float u_lightPower; 18 | 19 | float CreateCircle(vec2 position, float radius) { 20 | float circleShape = length(position); 21 | float circle = smoothstep(radius, radius + u_attenuation, 1.0 - circleShape); 22 | return circle; 23 | } 24 | 25 | void main() { 26 | vec2 uv = gl_FragCoord.xy / u_resolution.xy; 27 | 28 | float aspect = u_resolution.x / u_resolution.y; 29 | uv.x *= aspect; 30 | uv.y = 1.0 - uv.y; 31 | 32 | vec2 pos = u_position / u_resolution; 33 | float rad = 1.0 - (u_radius / u_resolution.x); 34 | 35 | vec4 pixel = texture2D(texture, i_tex); 36 | vec4 shadowPixel = texture2D(u_shadow, i_tex); 37 | 38 | float circleShape = CreateCircle(uv - pos, rad); 39 | 40 | shadowPixel *= circleShape; 41 | 42 | vec4 circle = vec4(1.0 - (u_color * circleShape) * u_lightPower, 1.0) + shadowPixel; 43 | 44 | o_color = pixel * circle; 45 | } -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | xcopy /y "libs\SFML\lib\PDB" "Sandbox\bin\Debug\*" 2 | start vendor\premake5.exe vs2022 -------------------------------------------------------------------------------- /include/ImGui/imconfig-SFML.h: -------------------------------------------------------------------------------- 1 | // Add this to your imconfig.h 2 | 3 | #include 4 | #include 5 | 6 | #include "imgui-SFML_export.h" 7 | 8 | #define IM_VEC2_CLASS_EXTRA \ 9 | template \ 10 | ImVec2(const sf::Vector2& v) { \ 11 | x = static_cast(v.x); \ 12 | y = static_cast(v.y); \ 13 | } \ 14 | \ 15 | template \ 16 | operator sf::Vector2() const { \ 17 | return sf::Vector2(x, y); \ 18 | } 19 | 20 | #define IM_VEC4_CLASS_EXTRA \ 21 | ImVec4(const sf::Color& c) : x(c.r / 255.f), y(c.g / 255.f), z(c.b / 255.f), w(c.a / 255.f) {} \ 22 | operator sf::Color() const { \ 23 | return sf::Color(static_cast(x * 255.f), static_cast(y * 255.f), \ 24 | static_cast(z * 255.f), static_cast(w * 255.f)); \ 25 | } 26 | 27 | #define ImTextureID unsigned int 28 | -------------------------------------------------------------------------------- /include/ImGui/imgui-SFML_export.h: -------------------------------------------------------------------------------- 1 | #ifndef IMGUI_SFML_EXPORT_H 2 | #define IMGUI_SFML_EXPORT_H 3 | 4 | #if IMGUI_SFML_SHARED_LIB 5 | #if _WIN32 6 | #ifdef IMGUI_SFML_EXPORTS 7 | #define IMGUI_SFML_API __declspec(dllexport) 8 | #define IMGUI_API __declspec(dllexport) 9 | #else 10 | #define IMGUI_SFML_API __declspec(dllimport) 11 | #define IMGUI_API __declspec(dllexport) 12 | #endif 13 | #elif __GNUC__ >= 4 14 | #define IMGUI_SFML_API __attribute__((visibility("default"))) 15 | #define IMGUI_API __attribute__((visibility("default"))) 16 | #else 17 | #define IMGUI_SFML_API 18 | #define IMGUI_API 19 | #endif 20 | #else 21 | #define IMGUI_SFML_API 22 | #define IMGUI_API 23 | #endif 24 | 25 | #endif -------------------------------------------------------------------------------- /include/Optick/optick_core.freebsd.h: -------------------------------------------------------------------------------- 1 | // The MIT License(MIT) 2 | // 3 | // Copyright(c) 2019 Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files(the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions : 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #pragma once 24 | #if defined(__FreeBSD__) 25 | 26 | #include "optick.config.h" 27 | #if USE_OPTICK 28 | 29 | #include "optick_core.platform.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Optick 37 | { 38 | const char* Platform::GetName() 39 | { 40 | return "PS4"; 41 | } 42 | 43 | ThreadID Platform::GetThreadID() 44 | { 45 | return (uint64_t)pthread_self(); 46 | } 47 | 48 | ProcessID Platform::GetProcessID() 49 | { 50 | return (ProcessID)getpid(); 51 | } 52 | 53 | int64 Platform::GetFrequency() 54 | { 55 | return 1000000000; 56 | } 57 | 58 | int64 Platform::GetTime() 59 | { 60 | struct timespec ts; 61 | clock_gettime(CLOCK_REALTIME, &ts); 62 | return ts.tv_sec * 1000000000LL + ts.tv_nsec; 63 | } 64 | 65 | Trace* Platform::CreateTrace() 66 | { 67 | return nullptr; 68 | } 69 | 70 | SymbolEngine* Platform::CreateSymbolEngine() 71 | { 72 | return nullptr; 73 | } 74 | } 75 | 76 | #endif //USE_OPTICK 77 | #endif //__FreeBSD__ -------------------------------------------------------------------------------- /include/Optick/optick_server.h: -------------------------------------------------------------------------------- 1 | // The MIT License(MIT) 2 | // 3 | // Copyright(c) 2019 Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files(the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions : 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #pragma once 24 | #include "optick.config.h" 25 | 26 | #if USE_OPTICK 27 | #include "optick_message.h" 28 | 29 | #include 30 | #include 31 | 32 | namespace Optick 33 | { 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 | class Socket; 36 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37 | class Server 38 | { 39 | InputDataStream networkStream; 40 | 41 | static const int BIFFER_SIZE = 1024; 42 | char buffer[BIFFER_SIZE]; 43 | 44 | Socket* socket; 45 | 46 | std::recursive_mutex socketLock; 47 | 48 | CaptureSaveChunkCb saveCb; 49 | 50 | Server( short port ); 51 | ~Server(); 52 | 53 | bool InitConnection(); 54 | 55 | void Send(const char* data, size_t size); 56 | 57 | public: 58 | void SetSaveCallback(CaptureSaveChunkCb cb); 59 | 60 | void SendStart(); 61 | void Send(DataResponse::Type type, OutputDataStream& stream); 62 | void SendFinish(); 63 | 64 | void Update(); 65 | 66 | string GetHostName() const; 67 | 68 | static Server &Get(); 69 | }; 70 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 71 | } 72 | 73 | #endif //USE_OPTICK -------------------------------------------------------------------------------- /include/SFML/Audio.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_HPP 26 | #define SFML_AUDIO_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | #endif // SFML_AUDIO_HPP 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \defgroup audio Audio module 52 | /// 53 | /// Sounds, streaming (musics or custom sources), recording, 54 | /// spatialization. 55 | /// 56 | //////////////////////////////////////////////////////////// 57 | -------------------------------------------------------------------------------- /include/SFML/Audio/AlResource.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_ALRESOURCE_HPP 26 | #define SFML_ALRESOURCE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | namespace sf 35 | { 36 | //////////////////////////////////////////////////////////// 37 | /// \brief Base class for classes that require an OpenAL context 38 | /// 39 | //////////////////////////////////////////////////////////// 40 | class SFML_AUDIO_API AlResource 41 | { 42 | protected: 43 | 44 | //////////////////////////////////////////////////////////// 45 | /// \brief Default constructor 46 | /// 47 | //////////////////////////////////////////////////////////// 48 | AlResource(); 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \brief Destructor 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | ~AlResource(); 55 | }; 56 | 57 | } // namespace sf 58 | 59 | 60 | #endif // SFML_ALRESOURCE_HPP 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \class sf::AlResource 64 | /// \ingroup audio 65 | /// 66 | /// This class is for internal use only, it must be the base 67 | /// of every class that requires a valid OpenAL context in 68 | /// order to work. 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | -------------------------------------------------------------------------------- /include/SFML/Audio/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_EXPORT_HPP 26 | #define SFML_AUDIO_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_AUDIO_EXPORTS) 38 | 39 | #define SFML_AUDIO_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_AUDIO_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_AUDIO_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /include/SFML/GpuPreference.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GPUPREFERENCE_HPP 26 | #define SFML_GPUPREFERENCE_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | /// Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | /// \file 37 | /// 38 | /// \brief File containing SFML_DEFINE_DISCRETE_GPU_PREFERENCE 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | 42 | 43 | //////////////////////////////////////////////////////////// 44 | /// \def SFML_DEFINE_DISCRETE_GPU_PREFERENCE 45 | /// 46 | /// \brief A macro to encourage usage of the discrete GPU 47 | /// 48 | /// In order to inform the Nvidia/AMD driver that an SFML 49 | /// application could benefit from using the more powerful 50 | /// discrete GPU, special symbols have to be publicly 51 | /// exported from the final executable. 52 | /// 53 | /// SFML defines a helper macro to easily do this. 54 | /// 55 | /// Place SFML_DEFINE_DISCRETE_GPU_PREFERENCE in the 56 | /// global scope of a source file that will be linked into 57 | /// the final executable. Typically it is best to place it 58 | /// where the main function is also defined. 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | #if defined(SFML_SYSTEM_WINDOWS) 62 | 63 | #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \ 64 | extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \ 65 | extern "C" __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1; 66 | 67 | #else 68 | 69 | #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE 70 | 71 | #endif 72 | 73 | 74 | #endif // SFML_GPUPREFERENCE_HPP 75 | -------------------------------------------------------------------------------- /include/SFML/Graphics.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_HPP 26 | #define SFML_GRAPHICS_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | 60 | 61 | #endif // SFML_GRAPHICS_HPP 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \defgroup graphics Graphics module 65 | /// 66 | /// 2D graphics module: sprites, text, shapes, ... 67 | /// 68 | //////////////////////////////////////////////////////////// 69 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_EXPORT_HPP 26 | #define SFML_GRAPHICS_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_GRAPHICS_EXPORTS) 38 | 39 | #define SFML_GRAPHICS_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_GRAPHICS_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_GRAPHICS_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /include/SFML/Graphics/PrimitiveType.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_PRIMITIVETYPE_HPP 26 | #define SFML_PRIMITIVETYPE_HPP 27 | 28 | namespace sf 29 | { 30 | //////////////////////////////////////////////////////////// 31 | /// \ingroup graphics 32 | /// \brief Types of primitives that a sf::VertexArray can render 33 | /// 34 | /// Points and lines have no area, therefore their thickness 35 | /// will always be 1 pixel, regardless the current transform 36 | /// and view. 37 | /// 38 | //////////////////////////////////////////////////////////// 39 | enum PrimitiveType 40 | { 41 | Points, //!< List of individual points 42 | Lines, //!< List of individual lines 43 | LineStrip, //!< List of connected lines, a point uses the previous point to form a line 44 | Triangles, //!< List of individual triangles 45 | TriangleStrip, //!< List of connected triangles, a point uses the two previous points to form a triangle 46 | TriangleFan //!< List of connected triangles, a point uses the common center and the previous point to form a triangle 47 | }; 48 | 49 | } // namespace sf 50 | 51 | 52 | #endif // SFML_PRIMITIVETYPE_HPP 53 | -------------------------------------------------------------------------------- /include/SFML/Main.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_MAIN_HPP 26 | #define SFML_MAIN_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | #if defined(SFML_SYSTEM_IOS) 35 | 36 | // On iOS, we have no choice but to have our own main, 37 | // so we need to rename the user one and call it later 38 | #define main sfmlMain 39 | 40 | #endif 41 | 42 | 43 | #endif // SFML_MAIN_HPP 44 | -------------------------------------------------------------------------------- /include/SFML/Network.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_HPP 26 | #define SFML_NETWORK_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | 45 | #endif // SFML_NETWORK_HPP 46 | 47 | //////////////////////////////////////////////////////////// 48 | /// \defgroup network Network module 49 | /// 50 | /// Socket-based communication, utilities and higher-level 51 | /// network protocols (HTTP, FTP). 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | -------------------------------------------------------------------------------- /include/SFML/Network/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_EXPORT_HPP 26 | #define SFML_NETWORK_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_NETWORK_EXPORTS) 38 | 39 | #define SFML_NETWORK_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_NETWORK_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_NETWORK_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /include/SFML/Network/SocketHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SOCKETHANDLE_HPP 26 | #define SFML_SOCKETHANDLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | #if defined(SFML_SYSTEM_WINDOWS) 34 | #include 35 | #endif 36 | 37 | 38 | namespace sf 39 | { 40 | //////////////////////////////////////////////////////////// 41 | // Define the low-level socket handle type, specific to 42 | // each platform 43 | //////////////////////////////////////////////////////////// 44 | #if defined(SFML_SYSTEM_WINDOWS) 45 | 46 | using SocketHandle = UINT_PTR; 47 | 48 | #else 49 | 50 | using SocketHandle = int; 51 | 52 | #endif 53 | 54 | } // namespace sf 55 | 56 | 57 | #endif // SFML_SOCKETHANDLE_HPP 58 | -------------------------------------------------------------------------------- /include/SFML/OpenGL.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_OPENGL_HPP 26 | #define SFML_OPENGL_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | /// Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | /// This file just includes the OpenGL headers, 37 | /// which have actually different paths on each system 38 | //////////////////////////////////////////////////////////// 39 | #if defined(SFML_SYSTEM_WINDOWS) 40 | 41 | // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them 42 | #ifdef _MSC_VER 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD) 49 | 50 | #if defined(SFML_OPENGL_ES) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #endif 56 | 57 | #elif defined(SFML_SYSTEM_MACOS) 58 | 59 | #include 60 | 61 | #elif defined (SFML_SYSTEM_IOS) 62 | 63 | #include 64 | #include 65 | 66 | #elif defined (SFML_SYSTEM_ANDROID) 67 | 68 | #include 69 | #include 70 | 71 | // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension 72 | #include 73 | #include 74 | 75 | #endif 76 | 77 | 78 | #endif // SFML_OPENGL_HPP 79 | -------------------------------------------------------------------------------- /include/SFML/System.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_HPP 26 | #define SFML_SYSTEM_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #endif // SFML_SYSTEM_HPP 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \defgroup system System module 55 | /// 56 | /// Base module of SFML, defining various utilities. It provides 57 | /// vector classes, Unicode strings and conversion functions, 58 | /// threads and mutexes, timing classes. 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | -------------------------------------------------------------------------------- /include/SFML/System/Err.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_ERR_HPP 26 | #define SFML_ERR_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Standard stream used by SFML to output warnings and errors 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | SFML_SYSTEM_API std::ostream& err(); 42 | 43 | } // namespace sf 44 | 45 | 46 | #endif // SFML_ERR_HPP 47 | 48 | 49 | //////////////////////////////////////////////////////////// 50 | /// \fn sf::err 51 | /// \ingroup system 52 | /// 53 | /// By default, sf::err() outputs to the same location as std::cerr, 54 | /// (-> the stderr descriptor) which is the console if there's 55 | /// one available. 56 | /// 57 | /// It is a standard std::ostream instance, so it supports all the 58 | /// insertion operations defined by the STL 59 | /// (operator <<, manipulators, etc.). 60 | /// 61 | /// sf::err() can be redirected to write to another output, independently 62 | /// of std::cerr, by using the rdbuf() function provided by the 63 | /// std::ostream class. 64 | /// 65 | /// Example: 66 | /// \code 67 | /// // Redirect to a file 68 | /// std::ofstream file("sfml-log.txt"); 69 | /// std::streambuf* previous = sf::err().rdbuf(file.rdbuf()); 70 | /// 71 | /// // Redirect to nothing 72 | /// sf::err().rdbuf(nullptr); 73 | /// 74 | /// // Restore the original output 75 | /// sf::err().rdbuf(previous); 76 | /// \endcode 77 | /// 78 | /// \return Reference to std::ostream representing the SFML error stream 79 | /// 80 | //////////////////////////////////////////////////////////// 81 | -------------------------------------------------------------------------------- /include/SFML/System/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_EXPORT_HPP 26 | #define SFML_SYSTEM_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_SYSTEM_EXPORTS) 38 | 39 | #define SFML_SYSTEM_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_SYSTEM_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_SYSTEM_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /include/SFML/System/NativeActivity.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NATIVEACTIVITY_HPP 26 | #define SFML_NATIVEACTIVITY_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | // Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | #if !defined(SFML_SYSTEM_ANDROID) 36 | #error NativeActivity.hpp: This header is Android only. 37 | #endif 38 | 39 | 40 | struct ANativeActivity; 41 | 42 | namespace sf 43 | { 44 | //////////////////////////////////////////////////////////// 45 | /// \ingroup system 46 | /// \brief Return a pointer to the Android native activity 47 | /// 48 | /// You shouldn't have to use this function, unless you want 49 | /// to implement very specific details, that SFML doesn't 50 | /// support, or to use a workaround for a known issue. 51 | /// 52 | /// \return Pointer to Android native activity structure 53 | /// 54 | /// \sfplatform{Android,SFML/System/NativeActivity.hpp} 55 | /// 56 | //////////////////////////////////////////////////////////// 57 | SFML_SYSTEM_API ANativeActivity* getNativeActivity(); 58 | 59 | } // namespace sf 60 | 61 | 62 | #endif // SFML_NATIVEACTIVITY_HPP 63 | -------------------------------------------------------------------------------- /include/SFML/System/Sleep.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SLEEP_HPP 26 | #define SFML_SLEEP_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \ingroup system 39 | /// \brief Make the current thread sleep for a given duration 40 | /// 41 | /// sf::sleep is the best way to block a program or one of its 42 | /// threads, as it doesn't consume any CPU power. 43 | /// 44 | /// \param duration Time to sleep 45 | /// 46 | //////////////////////////////////////////////////////////// 47 | void SFML_SYSTEM_API sleep(Time duration); 48 | 49 | } // namespace sf 50 | 51 | 52 | #endif // SFML_SLEEP_HPP 53 | -------------------------------------------------------------------------------- /include/SFML/System/String.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | String String::fromUtf8(T begin, T end) 29 | { 30 | String string; 31 | Utf8::toUtf32(begin, end, std::back_inserter(string.m_string)); 32 | return string; 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | String String::fromUtf16(T begin, T end) 39 | { 40 | String string; 41 | Utf16::toUtf32(begin, end, std::back_inserter(string.m_string)); 42 | return string; 43 | } 44 | 45 | 46 | //////////////////////////////////////////////////////////// 47 | template 48 | String String::fromUtf32(T begin, T end) 49 | { 50 | String string; 51 | string.m_string.assign(begin, end); 52 | return string; 53 | } 54 | -------------------------------------------------------------------------------- /include/SFML/System/Thread.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | namespace priv 26 | { 27 | // Base class for abstract thread functions 28 | struct ThreadFunc 29 | { 30 | virtual ~ThreadFunc() {} 31 | virtual void run() = 0; 32 | }; 33 | 34 | // Specialization using a functor (including free functions) with no argument 35 | template 36 | struct ThreadFunctor : ThreadFunc 37 | { 38 | ThreadFunctor(T functor) : m_functor(functor) {} 39 | void run() override {m_functor();} 40 | T m_functor; 41 | }; 42 | 43 | // Specialization using a functor (including free functions) with one argument 44 | template 45 | struct ThreadFunctorWithArg : ThreadFunc 46 | { 47 | ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {} 48 | void run() override {m_function(m_arg);} 49 | F m_function; 50 | A m_arg; 51 | }; 52 | 53 | // Specialization using a member function 54 | template 55 | struct ThreadMemberFunc : ThreadFunc 56 | { 57 | ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {} 58 | void run() override {(m_object->*m_function)();} 59 | void(C::*m_function)(); 60 | C* m_object; 61 | }; 62 | 63 | } // namespace priv 64 | 65 | 66 | //////////////////////////////////////////////////////////// 67 | template 68 | Thread::Thread(F functor) : 69 | m_impl (nullptr), 70 | m_entryPoint(new priv::ThreadFunctor(functor)) 71 | { 72 | } 73 | 74 | 75 | //////////////////////////////////////////////////////////// 76 | template 77 | Thread::Thread(F function, A argument) : 78 | m_impl (nullptr), 79 | m_entryPoint(new priv::ThreadFunctorWithArg(function, argument)) 80 | { 81 | } 82 | 83 | 84 | //////////////////////////////////////////////////////////// 85 | template 86 | Thread::Thread(void(C::*function)(), C* object) : 87 | m_impl (nullptr), 88 | m_entryPoint(new priv::ThreadMemberFunc(function, object)) 89 | { 90 | } 91 | -------------------------------------------------------------------------------- /include/SFML/System/ThreadLocalPtr.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | namespace sf 27 | { 28 | //////////////////////////////////////////////////////////// 29 | template 30 | ThreadLocalPtr::ThreadLocalPtr(T* value) : 31 | ThreadLocal(value) 32 | { 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | T& ThreadLocalPtr::operator *() const 39 | { 40 | return *static_cast(getValue()); 41 | } 42 | 43 | 44 | //////////////////////////////////////////////////////////// 45 | template 46 | T* ThreadLocalPtr::operator ->() const 47 | { 48 | return static_cast(getValue()); 49 | } 50 | 51 | 52 | //////////////////////////////////////////////////////////// 53 | template 54 | ThreadLocalPtr::operator T*() const 55 | { 56 | return static_cast(getValue()); 57 | } 58 | 59 | 60 | //////////////////////////////////////////////////////////// 61 | template 62 | ThreadLocalPtr& ThreadLocalPtr::operator =(T* value) 63 | { 64 | setValue(value); 65 | return *this; 66 | } 67 | 68 | 69 | //////////////////////////////////////////////////////////// 70 | template 71 | ThreadLocalPtr& ThreadLocalPtr::operator =(const ThreadLocalPtr& right) 72 | { 73 | setValue(right.getValue()); 74 | return *this; 75 | } 76 | 77 | } // namespace sf 78 | -------------------------------------------------------------------------------- /include/SFML/Window.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SFML_WINDOW_HPP 26 | #define SFML_SFML_WINDOW_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | 49 | 50 | #endif // SFML_SFML_WINDOW_HPP 51 | 52 | //////////////////////////////////////////////////////////// 53 | /// \defgroup window Window module 54 | /// 55 | /// Provides OpenGL-based windows, and abstractions for 56 | /// events and input handling. 57 | /// 58 | //////////////////////////////////////////////////////////// 59 | -------------------------------------------------------------------------------- /include/SFML/Window/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOW_EXPORT_HPP 26 | #define SFML_WINDOW_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_WINDOW_EXPORTS) 38 | 39 | #define SFML_WINDOW_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_WINDOW_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_WINDOW_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /include/SFML/Window/WindowStyle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOWSTYLE_HPP 26 | #define SFML_WINDOWSTYLE_HPP 27 | 28 | 29 | namespace sf 30 | { 31 | namespace Style 32 | { 33 | //////////////////////////////////////////////////////////// 34 | /// \ingroup window 35 | /// \brief Enumeration of the window styles 36 | /// 37 | //////////////////////////////////////////////////////////// 38 | enum 39 | { 40 | None = 0, //!< No border / title bar (this flag and all others are mutually exclusive) 41 | Titlebar = 1 << 0, //!< Title bar + fixed border 42 | Resize = 1 << 1, //!< Title bar + resizable border + maximize button 43 | Close = 1 << 2, //!< Title bar + close button 44 | Fullscreen = 1 << 3, //!< Fullscreen mode (this flag and all others are mutually exclusive) 45 | 46 | Default = Titlebar | Resize | Close //!< Default window style 47 | }; 48 | } 49 | 50 | } // namespace sf 51 | 52 | 53 | #endif // SFML_WINDOWSTYLE_HPP 54 | -------------------------------------------------------------------------------- /include/box2d/b2_api.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_API_H 24 | #define B2_API_H 25 | 26 | #ifdef B2_SHARED 27 | #if defined _WIN32 || defined __CYGWIN__ 28 | #ifdef box2d_EXPORTS 29 | #ifdef __GNUC__ 30 | #define B2_API __attribute__ ((dllexport)) 31 | #else 32 | #define B2_API __declspec(dllexport) 33 | #endif 34 | #else 35 | #ifdef __GNUC__ 36 | #define B2_API __attribute__ ((dllimport)) 37 | #else 38 | #define B2_API __declspec(dllimport) 39 | #endif 40 | #endif 41 | #else 42 | #if __GNUC__ >= 4 43 | #define B2_API __attribute__ ((visibility ("default"))) 44 | #else 45 | #define B2_API 46 | #endif 47 | #endif 48 | #else 49 | #define B2_API 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/box2d/b2_block_allocator.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_BLOCK_ALLOCATOR_H 24 | #define B2_BLOCK_ALLOCATOR_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | const int32 b2_blockSizeCount = 14; 30 | 31 | struct b2Block; 32 | struct b2Chunk; 33 | 34 | /// This is a small object allocator used for allocating small 35 | /// objects that persist for more than one time step. 36 | /// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp 37 | class B2_API b2BlockAllocator 38 | { 39 | public: 40 | b2BlockAllocator(); 41 | ~b2BlockAllocator(); 42 | 43 | /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize. 44 | void* Allocate(int32 size); 45 | 46 | /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize. 47 | void Free(void* p, int32 size); 48 | 49 | void Clear(); 50 | 51 | private: 52 | 53 | b2Chunk* m_chunks; 54 | int32 m_chunkCount; 55 | int32 m_chunkSpace; 56 | 57 | b2Block* m_freeLists[b2_blockSizeCount]; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/box2d/b2_circle_shape.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CIRCLE_SHAPE_H 24 | #define B2_CIRCLE_SHAPE_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_shape.h" 28 | 29 | /// A solid circle shape 30 | class B2_API b2CircleShape : public b2Shape 31 | { 32 | public: 33 | b2CircleShape(); 34 | 35 | /// Implement b2Shape. 36 | b2Shape* Clone(b2BlockAllocator* allocator) const override; 37 | 38 | /// @see b2Shape::GetChildCount 39 | int32 GetChildCount() const override; 40 | 41 | /// Implement b2Shape. 42 | bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override; 43 | 44 | /// Implement b2Shape. 45 | /// @note because the circle is solid, rays that start inside do not hit because the normal is 46 | /// not defined. 47 | bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, 48 | const b2Transform& transform, int32 childIndex) const override; 49 | 50 | /// @see b2Shape::ComputeAABB 51 | void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override; 52 | 53 | /// @see b2Shape::ComputeMass 54 | void ComputeMass(b2MassData* massData, float density) const override; 55 | 56 | /// Position 57 | b2Vec2 m_p; 58 | }; 59 | 60 | inline b2CircleShape::b2CircleShape() 61 | { 62 | m_type = e_circle; 63 | m_radius = 0.0f; 64 | m_p.SetZero(); 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/box2d/b2_contact_manager.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CONTACT_MANAGER_H 24 | #define B2_CONTACT_MANAGER_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_broad_phase.h" 28 | 29 | class b2Contact; 30 | class b2ContactFilter; 31 | class b2ContactListener; 32 | class b2BlockAllocator; 33 | 34 | // Delegate of b2World. 35 | class B2_API b2ContactManager 36 | { 37 | public: 38 | b2ContactManager(); 39 | 40 | // Broad-phase callback. 41 | void AddPair(void* proxyUserDataA, void* proxyUserDataB); 42 | 43 | void FindNewContacts(); 44 | 45 | void Destroy(b2Contact* c); 46 | 47 | void Collide(); 48 | 49 | b2BroadPhase m_broadPhase; 50 | b2Contact* m_contactList; 51 | int32 m_contactCount; 52 | b2ContactFilter* m_contactFilter; 53 | b2ContactListener* m_contactListener; 54 | b2BlockAllocator* m_allocator; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/box2d/b2_growable_stack.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_GROWABLE_STACK_H 24 | #define B2_GROWABLE_STACK_H 25 | 26 | #include 27 | 28 | #include "b2_settings.h" 29 | 30 | /// This is a growable LIFO stack with an initial capacity of N. 31 | /// If the stack size exceeds the initial capacity, the heap is used 32 | /// to increase the size of the stack. 33 | template 34 | class b2GrowableStack 35 | { 36 | public: 37 | b2GrowableStack() 38 | { 39 | m_stack = m_array; 40 | m_count = 0; 41 | m_capacity = N; 42 | } 43 | 44 | ~b2GrowableStack() 45 | { 46 | if (m_stack != m_array) 47 | { 48 | b2Free(m_stack); 49 | m_stack = nullptr; 50 | } 51 | } 52 | 53 | void Push(const T& element) 54 | { 55 | if (m_count == m_capacity) 56 | { 57 | T* old = m_stack; 58 | m_capacity *= 2; 59 | m_stack = (T*)b2Alloc(m_capacity * sizeof(T)); 60 | memcpy(m_stack, old, m_count * sizeof(T)); 61 | if (old != m_array) 62 | { 63 | b2Free(old); 64 | } 65 | } 66 | 67 | m_stack[m_count] = element; 68 | ++m_count; 69 | } 70 | 71 | T Pop() 72 | { 73 | b2Assert(m_count > 0); 74 | --m_count; 75 | return m_stack[m_count]; 76 | } 77 | 78 | int32 GetCount() 79 | { 80 | return m_count; 81 | } 82 | 83 | private: 84 | T* m_stack; 85 | T m_array[N]; 86 | int32 m_count; 87 | int32 m_capacity; 88 | }; 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/box2d/b2_stack_allocator.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_STACK_ALLOCATOR_H 24 | #define B2_STACK_ALLOCATOR_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | const int32 b2_stackSize = 100 * 1024; // 100k 30 | const int32 b2_maxStackEntries = 32; 31 | 32 | struct B2_API b2StackEntry 33 | { 34 | char* data; 35 | int32 size; 36 | bool usedMalloc; 37 | }; 38 | 39 | // This is a stack allocator used for fast per step allocations. 40 | // You must nest allocate/free pairs. The code will assert 41 | // if you try to interleave multiple allocate/free pairs. 42 | class B2_API b2StackAllocator 43 | { 44 | public: 45 | b2StackAllocator(); 46 | ~b2StackAllocator(); 47 | 48 | void* Allocate(int32 size); 49 | void Free(void* p); 50 | 51 | int32 GetMaxAllocation() const; 52 | 53 | private: 54 | 55 | char m_data[b2_stackSize]; 56 | int32 m_index; 57 | 58 | int32 m_allocation; 59 | int32 m_maxAllocation; 60 | 61 | b2StackEntry m_entries[b2_maxStackEntries]; 62 | int32 m_entryCount; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/box2d/b2_time_of_impact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TIME_OF_IMPACT_H 24 | #define B2_TIME_OF_IMPACT_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_math.h" 28 | #include "b2_distance.h" 29 | 30 | /// Input parameters for b2TimeOfImpact 31 | struct B2_API b2TOIInput 32 | { 33 | b2DistanceProxy proxyA; 34 | b2DistanceProxy proxyB; 35 | b2Sweep sweepA; 36 | b2Sweep sweepB; 37 | float tMax; // defines sweep interval [0, tMax] 38 | }; 39 | 40 | /// Output parameters for b2TimeOfImpact. 41 | struct B2_API b2TOIOutput 42 | { 43 | enum State 44 | { 45 | e_unknown, 46 | e_failed, 47 | e_overlapped, 48 | e_touching, 49 | e_separated 50 | }; 51 | 52 | State state; 53 | float t; 54 | }; 55 | 56 | /// Compute the upper bound on time before two shapes penetrate. Time is represented as 57 | /// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, 58 | /// non-tunneling collisions. If you change the time interval, you should call this function 59 | /// again. 60 | /// Note: use b2Distance to compute the contact point and normal at the time of impact. 61 | B2_API void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/box2d/b2_time_step.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | #ifndef B2_TIME_STEP_H 23 | #define B2_TIME_STEP_H 24 | 25 | #include "b2_api.h" 26 | #include "b2_math.h" 27 | 28 | /// Profiling data. Times are in milliseconds. 29 | struct B2_API b2Profile 30 | { 31 | float step; 32 | float collide; 33 | float solve; 34 | float solveInit; 35 | float solveVelocity; 36 | float solvePosition; 37 | float broadphase; 38 | float solveTOI; 39 | }; 40 | 41 | /// This is an internal structure. 42 | struct B2_API b2TimeStep 43 | { 44 | float dt; // time step 45 | float inv_dt; // inverse time step (0 if dt == 0). 46 | float dtRatio; // dt * inv_dt0 47 | int32 velocityIterations; 48 | int32 positionIterations; 49 | bool warmStarting; 50 | }; 51 | 52 | /// This is an internal structure. 53 | struct B2_API b2Position 54 | { 55 | b2Vec2 c; 56 | float a; 57 | }; 58 | 59 | /// This is an internal structure. 60 | struct B2_API b2Velocity 61 | { 62 | b2Vec2 v; 63 | float w; 64 | }; 65 | 66 | /// Solver Data 67 | struct B2_API b2SolverData 68 | { 69 | b2TimeStep step; 70 | b2Position* positions; 71 | b2Velocity* velocities; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/box2d/b2_timer.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TIMER_H 24 | #define B2_TIMER_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | /// Timer for profiling. This has platform specific code and may 30 | /// not work on every platform. 31 | class B2_API b2Timer 32 | { 33 | public: 34 | 35 | /// Constructor 36 | b2Timer(); 37 | 38 | /// Reset the timer. 39 | void Reset(); 40 | 41 | /// Get the time since construction or the last reset. 42 | float GetMilliseconds() const; 43 | 44 | private: 45 | 46 | #if defined(_WIN32) 47 | double m_start; 48 | static double s_invFrequency; 49 | #elif defined(__linux__) || defined (__APPLE__) 50 | unsigned long long m_start_sec; 51 | unsigned long long m_start_usec; 52 | #endif 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/box2d/b2_types.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2020 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TYPES_H 24 | #define B2_TYPES_H 25 | 26 | typedef signed char int8; 27 | typedef signed short int16; 28 | typedef signed int int32; 29 | typedef unsigned char uint8; 30 | typedef unsigned short uint16; 31 | typedef unsigned int uint32; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /include/box2d/box2d.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef BOX2D_H 24 | #define BOX2D_H 25 | 26 | // These include files constitute the main Box2D API 27 | 28 | #include "b2_settings.h" 29 | #include "b2_draw.h" 30 | #include "b2_timer.h" 31 | 32 | #include "b2_chain_shape.h" 33 | #include "b2_circle_shape.h" 34 | #include "b2_edge_shape.h" 35 | #include "b2_polygon_shape.h" 36 | 37 | #include "b2_broad_phase.h" 38 | #include "b2_dynamic_tree.h" 39 | 40 | #include "b2_body.h" 41 | #include "b2_contact.h" 42 | #include "b2_fixture.h" 43 | #include "b2_time_step.h" 44 | #include "b2_world.h" 45 | #include "b2_world_callbacks.h" 46 | 47 | #include "b2_distance_joint.h" 48 | #include "b2_friction_joint.h" 49 | #include "b2_gear_joint.h" 50 | #include "b2_motor_joint.h" 51 | #include "b2_mouse_joint.h" 52 | #include "b2_prismatic_joint.h" 53 | #include "b2_pulley_joint.h" 54 | #include "b2_revolute_joint.h" 55 | #include "b2_weld_joint.h" 56 | #include "b2_wheel_joint.h" 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libs/Optick/lib/Debug/OptickCore.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/Optick/lib/Debug/OptickCore.lib -------------------------------------------------------------------------------- /libs/Optick/lib/Release/OptickCore.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/Optick/lib/Release/OptickCore.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/flac.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/flac.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/freetype.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/freetype.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/ogg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/ogg.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/openal32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/openal32.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/vorbis.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/vorbis.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/vorbisenc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/vorbisenc.lib -------------------------------------------------------------------------------- /libs/SFML/extlibs/vorbisfile.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/extlibs/vorbisfile.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-audio-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-audio-s-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-graphics-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-graphics-s-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-main-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-main-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-network-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-network-s-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-system-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-system-s-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Debug/sfml-window-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Debug/sfml-window-s-d.lib -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-audio-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-audio-s-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-audio-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-audio-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-graphics-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-graphics-s-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-graphics-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-graphics-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-main-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-main-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-main-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-main-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-network-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-network-s-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-network-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-network-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-system-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-system-s-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-system-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-system-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-window-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-window-s-d.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/PDB/sfml-window-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/PDB/sfml-window-s.pdb -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-audio-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-audio-s.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-graphics-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-graphics-s.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-main.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-network-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-network-s.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-system-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-system-s.lib -------------------------------------------------------------------------------- /libs/SFML/lib/Release/sfml-window-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/libs/SFML/lib/Release/sfml-window-s.lib -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | -- premake5.lua 2 | workspace "Heavy Engine" 3 | startproject "Sandbox" 4 | architecture "x64" 5 | configurations { 6 | "Debug", 7 | "Release" 8 | } 9 | 10 | filter { "platforms:Win64" } 11 | system "Windows" 12 | 13 | include "Heavy" 14 | include "Sandbox" -------------------------------------------------------------------------------- /vendor/license.readme: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2019 Jason Perkins and individual contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Premake nor the names of its contributors may be 15 | used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/Heavy/a2739f0320b57be81fa3e9adb991f7374568c8b9/vendor/premake5.exe --------------------------------------------------------------------------------