Skip to content

Commit

Permalink
Collision Detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed May 1, 2024
1 parent 260b88d commit 00e1874
Show file tree
Hide file tree
Showing 47 changed files with 77 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Drizzle3D/AppEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,15 @@ namespace Drizzle3D {

Drizzle3D_API EventType GetEventType() override { return EventType::AppRender; }
};

class ObjectColliderEvent : public Event {
public:
Drizzle3D_API ObjectColliderEvent(std::vector<std::string> col) : collided(col) {};

Drizzle3D_API std::vector<std::string> GetColliders() { return collided; }

Drizzle3D_API EventType GetEventType() override { return EventType::Collided; }
private:
std::vector<std::string> collided;
};
}
6 changes: 6 additions & 0 deletions Drizzle3D/CollisionDetection.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
#include "CollisionDetection.h"

namespace Drizzle3D {
void CollisionDetection::CheckCollision() {
// Create Collision Event
}
}
6 changes: 4 additions & 2 deletions Drizzle3D/CollisionDetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
#include <vector>
#include <string>
#include "base.h"
#include "Events.h"

namespace Drizzle3D {
class CollisionDetection {
public:
CollisionDetection(std::vector<std::tuple<std::string, std::vector<float>, std::vector<unsigned int>>> col) : colliders(col) {}
std::vector<std::string> CheckCollision();
Drizzle3D_API CollisionDetection(std::vector<std::tuple<std::string, std::vector<float>, std::vector<unsigned int>>> col, std::shared_ptr<EventDispatcher> disp) : colliders(col), dispatcher(disp) {}
Drizzle3D_API void CheckCollision();

private:
std::vector<std::tuple<std::string, std::vector<float>, std::vector<unsigned int>>> colliders;
std::shared_ptr<EventDispatcher> dispatcher;
};
}
3 changes: 2 additions & 1 deletion Drizzle3D/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace Drizzle3D {
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved,
AppTick, AppUpdate, AppRender,
KeyPressed, KeyReleased,
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled,
Collided
};

class Event {
Expand Down
Binary file modified Drizzle3D/x64/Debug/App.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Camera.obj
Binary file not shown.
Binary file added Drizzle3D/x64/Debug/CollisionDetection.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.ilk
Binary file not shown.
23 changes: 23 additions & 0 deletions Drizzle3D/x64/Debug/Drizzle3D.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(517,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
Scanning sources for module dependencies...
App.cpp
Camera.cpp
CollisionDetection.cpp
FirstPersonCamera.cpp
ImGuiLayer.cpp
Layer.cpp
Light.cpp
D:\Drizzle3D\Drizzle3D\Light.cpp(13,16): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
main.cpp
Object.cpp
OpenGL.cpp
D:\Drizzle3D\Drizzle3D\OpenGL.cpp(184,59): warning C4267: 'argument': conversion from 'size_t' to 'GLsizei', possible loss of data
RenderingLayer.cpp
Renderer2D.cpp
Shader.cpp
Skybox.cpp
Vulkan.cpp
Window.cpp
Generating Code...
D:\Drizzle3D\Drizzle3D\RenderingLayer.cpp(192,1): warning C4715: 'Drizzle3D::RenderingLayer::GetTexture': not all control paths return a value
D:\Drizzle3D\Drizzle3D\Camera.cpp(46,1): warning C4715: 'Drizzle3D::RenderingLayer::ReturnActiveCamera': not all control paths return a value
D:\Drizzle3D\Drizzle3D\Camera.cpp(54,1): warning C4715: 'Drizzle3D::RenderingLayer::GetCameraFromID': not all control paths return a value
Creating library D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.lib and object D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
Drizzle3D.vcxproj -> D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.dll
D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.dll
1 File(s) copied
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.write.1.tlog
Binary file not shown.
1 change: 1 addition & 0 deletions Drizzle3D/x64/Debug/Drizzle3D.tlog/Cl.items.tlog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
D:\Drizzle3D\Drizzle3D\App.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\App.obj
D:\Drizzle3D\Drizzle3D\Camera.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\Camera.obj
D:\Drizzle3D\Drizzle3D\CollisionDetection.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\CollisionDetection.obj
D:\Drizzle3D\Drizzle3D\Events.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\Events.obj
D:\Drizzle3D\Drizzle3D\FirstPersonCamera.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\FirstPersonCamera.obj
D:\Drizzle3D\Drizzle3D\Flags.cpp;D:\Drizzle3D\Drizzle3D\x64\Debug\Flags.obj
Expand Down
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.read.1.tlog
Binary file not shown.
2 changes: 1 addition & 1 deletion Drizzle3D/x64/Debug/Drizzle3D.tlog/link.secondary.1.tlog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
^D:\DRIZZLE3D\DRIZZLE3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ZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_WIDGETS.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\LAYER.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\LIGHT.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\LOGGING.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\MAIN.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\MATERIAL.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\OBJECT.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\OPENGL.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\RENDERER2D.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\RENDERINGLAYER.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\RESOURCEMANAGER.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\SHADER.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\SKYBOX.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\VKBOOTSTRAP.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\VULKAN.OBJ|D:\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\WINDOW.OBJ
D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.lib
D:\Drizzle3D\ExampleProject\vendor\Drizzle3D\Drizzle3D.EXP
D:\Drizzle3D\Drizzle3D\x64\Debug\Drizzle3D.ilk
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.write.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Events.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/FirstPersonCamera.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/ImGuiLayer.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Layer.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Light.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Object.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/OpenGL.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Renderer2D.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/RenderingLayer.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Shader.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Skybox.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Vulkan.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Window.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/main.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/vc143.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion ExampleProject/ExampleProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main() {
* NOTE:
* Key Released and Mouse Released
*/
std::shared_ptr<Drizzle3D::App> app = std::make_shared<Drizzle3D::App>(Drizzle3D::RenderingAPI::Vulkan);
std::shared_ptr<Drizzle3D::App> app = std::make_shared<Drizzle3D::App>(Drizzle3D::RenderingAPI::OpenGL);

app->GetRenderingLayer()->GetFlags()->ChangeFlag("Lighting", false);

Expand Down
2 changes: 1 addition & 1 deletion ExampleProject/imgui.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Window][Debug##Default]
Pos=80,63
Pos=81,63
Size=339,531

[Window][Dear ImGui Demo]
Expand Down
Binary file modified ExampleProject/vendor/Drizzle3D/Drizzle3D.dll
Binary file not shown.
Binary file modified ExampleProject/vendor/Drizzle3D/Drizzle3D.exp
Binary file not shown.
28 changes: 27 additions & 1 deletion ExampleProject/vendor/Drizzle3D/Drizzle3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,8 @@ namespace Drizzle3D {
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved,
AppTick, AppUpdate, AppRender,
KeyPressed, KeyReleased,
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled,
Collided
};

class Event {
Expand Down Expand Up @@ -2205,6 +2206,17 @@ namespace Drizzle3D {
MouseCode m_Button;
};

class ObjectColliderEvent : public Event {
public:
Drizzle3D_API ObjectColliderEvent(std::vector<std::string> col) : collided(col) {};

Drizzle3D_API std::vector<std::string> GetColliders() { return collided; }

Drizzle3D_API EventType GetEventType() override { return EventType::Collided; }
private:
std::vector<std::string> collided;
};

/*
* Resource Manager
*/
Expand Down Expand Up @@ -2578,6 +2590,20 @@ namespace Drizzle3D {
RenderingAPI renderingAPI;
};

/*
* Collision Detection
*/

class CollisionDetection {
public:
Drizzle3D_API CollisionDetection(std::vector<std::tuple<std::string, std::vector<float>, std::vector<unsigned int>>> col, std::shared_ptr<EventDispatcher> disp) : colliders(col), dispatcher(disp) {}
Drizzle3D_API void CheckCollision();

private:
std::vector<std::tuple<std::string, std::vector<float>, std::vector<unsigned int>>> colliders;
std::shared_ptr<EventDispatcher> dispatcher;
};

/*
* App
*/
Expand Down
Binary file modified ExampleProject/vendor/Drizzle3D/Drizzle3D.lib
Binary file not shown.
Binary file modified ExampleProject/vendor/Drizzle3D/Drizzle3D.pdb
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/Drizzle3D.dll
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/ExampleProject.exe
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/ExampleProject.ilk
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/ExampleProject.obj
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/ExampleProject.pdb
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/vc143.pdb
Binary file not shown.

0 comments on commit 00e1874

Please sign in to comment.