Browse Source

banana gun

vlod 6 months ago
parent
commit
85044fcf25

+ 32 - 4
Pika/gameplay/containers/milk/milk.h

@@ -203,6 +203,8 @@ struct Milk: public Container
 		renderer.init(1, 1, PIKA_RESOURCES_PATH "BRDFintegrationMap.png", requestedInfo.requestedFBO.fbo);
 
 		renderer.adaptiveResolution.useAdaptiveResolution = false;
+		renderer.frustumCulling = false;
+		
 
 		//renderer.skyBox = renderer.atmosfericScattering({0.2,1,0.3}, {0.9,0.1,0.1}, {0.4, 0.4, 0.8}, 0.8f); //todo a documentation
 		//todo api for skybox stuff
@@ -269,21 +271,21 @@ struct Milk: public Container
 	bool update(pika::Input input, pika::WindowState windowState,
 		RequestedContainerInfo &requestedInfo)
 	{
-	
+
 	#pragma region frame start stuff
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
 		renderer.fileOpener.readEntireFileBinaryCallback = readEntireFileBinaryCustom;
 		renderer.fileOpener.readEntireFileCallback = readEntireFileCustom;
 		renderer.fileOpener.fileExistsCallback = defaultFileExistsCustom;
-		
+
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 		glEnable(GL_DEPTH_TEST);
 
 		renderer.updateWindowMetrics(windowState.windowW, windowState.windowH);
 		renderer.camera.aspectRatio = (float)windowState.windowW / windowState.windowH; //todo do this in update
 
-		
+
 		editor.update(requestedInfo.requestedImguiIds, renderer, input, 0, requestedInfo, {windowState.windowW,windowState.windowH});
 
 		auto &playerObject = simulator.bodies[playerPhysics];
@@ -336,13 +338,39 @@ struct Milk: public Container
 				playerObject.velocity += move;
 			}
 
-			if (input.buttons[pika::Button::Space].pressed())
+			if (input.buttons[pika::Button::Space].pressed() && playerObject.collidesBottom)
 			{
 				playerObject.velocity.y += 10.f;
 			}
 
 		}
 
+		if (playerObject.collidesSide && !playerObject.collidesBottom)
+		{
+			glm::vec3 moveVelocity = playerObject.velocity;
+			moveVelocity.y = 0;
+
+			float l = glm::length(moveVelocity);
+
+			if (l > 5.f)
+			{
+				playerObject.acceleration -= glm::vec3{0, -9.81, 0} *0.7f;
+			}
+
+			if (input.buttons[pika::Button::Space].pressed())
+			{
+				playerObject.velocity.y += 8.f;
+
+				float l = glm::length(playerObject.collisionVector);
+				if (l > 0)
+				{
+					playerObject.velocity += (playerObject.collisionVector / l) * 5.f;
+				}
+			}
+
+		}
+
+
 		renderer.camera.position = playerObject.position + glm::vec3(0, 0.7, 0);
 
 

+ 32 - 1
Pika/gameplay/containers/milk/physics.cpp

@@ -121,21 +121,49 @@ bool AABBvsAABB(PhysicsObject &a, PhysicsObject &b, float &penetration, glm::vec
 	// SAT test on x, y, and z axes
 	if (x_overlap > 0 && y_overlap > 0 && z_overlap > 0)
 	{
-		// Determine the axis of least penetration
 		if (x_overlap < y_overlap && x_overlap < z_overlap)
 		{
 			normal = (n.x < 0) ? glm::vec3(-1, 0, 0) : glm::vec3(1, 0, 0);
 			penetration = x_overlap;
+
+			// Side collision on X axis
+			a.collidesSide = true;
+			b.collidesSide = true;
+
+			a.collisionVector = -normal;
+			b.collisionVector = normal;
 		}
 		else if (y_overlap < z_overlap)
 		{
 			normal = (n.y < 0) ? glm::vec3(0, -1, 0) : glm::vec3(0, 1, 0);
 			penetration = y_overlap;
+
+			if (normal.y > 0)
+			{
+				// 'b' hit 'a' on its bottom
+				b.collidesBottom = true;
+				a.collidesSide = true;
+			}
+			else
+			{
+				// 'a' hit 'b' on its bottom
+				a.collidesBottom = true;
+				b.collidesSide = true;
+			}
+
+			// No collisionVector for bottom/top
 		}
 		else
 		{
 			normal = (n.z < 0) ? glm::vec3(0, 0, -1) : glm::vec3(0, 0, 1);
 			penetration = z_overlap;
+
+			// Side collision on Z axis
+			a.collidesSide = true;
+			b.collidesSide = true;
+
+			a.collisionVector = -normal;
+			b.collisionVector = normal;
 		}
 		return true;
 	}
@@ -667,6 +695,9 @@ void Simulator::update(float deltaTime)
 
 		//gravity
 		b.acceleration += glm::vec3{0, -9.81, 0};
+		b.collidesBottom = 0;
+		b.collidesSide = 0;
+		b.collisionVector = {};
 
 		if(b.mass != 0 && b.mass != INFINITY)
 		applyDrag(b);

+ 6 - 0
Pika/gameplay/containers/milk/physics.h

@@ -25,6 +25,9 @@ struct PhysicsObject
 
 	glm::vec3 acceleration = {};
 
+	glm::vec3 collisionDir = {};
+
+
 	float mass = 1;
 	float bouncyness = 0.9;
 	int type = 0;
@@ -32,6 +35,9 @@ struct PhysicsObject
 
 	float dynamicFriction = 0.3;
 
+	bool collidesBottom = 0;
+	bool collidesSide = 0;
+	glm::vec3 collisionVector = {};
 
 	glm::vec3 getMin()
 	{

+ 44 - 37
Pika/resources/logs.txt

@@ -1,37 +1,44 @@
-#2025-05-16 19:28:49: Created container: Milk
-#2025-05-16 19:32:53[warning]: Couldn't reloaded dll
-#2025-05-16 19:32:56: Reloaded dll
-#2025-05-16 19:33:04: Destroyed continer: Milk #1
-#2025-05-16 19:33:18[warning]: Couldn't reloaded dll
-#2025-05-16 19:33:20: Reloaded dll
-#2025-05-16 19:33:23: Created container: Milk
-#2025-05-16 19:33:28: Destroyed continer: Milk #2
-#2025-05-16 19:33:43[warning]: Couldn't reloaded dll
-#2025-05-16 19:33:45[warning]: Couldn't reloaded dll
-#2025-05-16 19:33:46: Reloaded dll
-#2025-05-16 19:33:49: Created container: Milk
-#2025-05-16 19:34:35[warning]: Couldn't reloaded dll
-#2025-05-16 19:34:37[warning]: Couldn't reloaded dll
-#2025-05-16 19:34:37: Reloaded dll
-#2025-05-16 19:34:55: Destroyed continer: Milk #3
-#2025-05-16 19:34:57: Created container: Milk
-#2025-05-16 19:35:03: Destroyed continer: Milk #4
-#2025-05-16 19:35:28[warning]: Couldn't reloaded dll
-#2025-05-16 19:35:30: Reloaded dll
-#2025-05-16 19:35:35: Created container: Milk
-#2025-05-16 19:36:36[warning]: Couldn't reloaded dll
-#2025-05-16 19:36:39: Reloaded dll
-#2025-05-16 19:37:37[warning]: Couldn't reloaded dll
-#2025-05-16 19:37:39[warning]: Couldn't reloaded dll
-#2025-05-16 19:37:40: Reloaded dll
-#2025-05-16 19:38:12[warning]: Couldn't reloaded dll
-#2025-05-16 19:38:15[warning]: Couldn't reloaded dll
-#2025-05-16 19:38:15: Reloaded dll
-#2025-05-16 19:38:45: Destroyed continer: Milk #5
-#2025-05-16 19:39:18[warning]: Couldn't reloaded dll
-#2025-05-16 19:39:20: Reloaded dll
-#2025-05-16 19:39:23: Created container: Milk
-#2025-05-16 19:40:03[warning]: Couldn't reloaded dll
-#2025-05-16 19:40:05[warning]: Couldn't reloaded dll
-#2025-05-16 19:40:05: Reloaded dll
-#2025-05-16 19:40:50: Destroyed continer: Milk #6
+#2025-05-26 23:48:52[warning]: Couldn't reloaded dll
+#2025-05-26 23:48:54: Reloaded dll
+#2025-05-26 23:49:21[warning]: Couldn't reloaded dll
+#2025-05-26 23:49:23: Reloaded dll
+#2025-05-26 23:49:26: Created container: Milk
+#2025-05-26 23:50:01[warning]: Couldn't reloaded dll
+#2025-05-26 23:50:02: Reloaded dll
+#2025-05-26 23:50:51[warning]: Couldn't reloaded dll
+#2025-05-26 23:50:54: Reloaded dll
+#2025-05-26 23:52:03[warning]: Couldn't reloaded dll
+#2025-05-26 23:52:05: Reloaded dll
+#2025-05-26 23:52:48[warning]: Couldn't reloaded dll
+#2025-05-26 23:52:50: Reloaded dll
+#2025-05-26 23:53:14[warning]: Couldn't reloaded dll
+#2025-05-26 23:53:16[warning]: Couldn't reloaded dll
+#2025-05-26 23:53:17: Reloaded dll
+#2025-05-26 23:54:01[warning]: Couldn't reloaded dll
+#2025-05-26 23:54:03[warning]: Couldn't reloaded dll
+#2025-05-26 23:54:03: Reloaded dll
+#2025-05-26 23:55:12[warning]: Couldn't reloaded dll
+#2025-05-26 23:55:14[warning]: Couldn't reloaded dll
+#2025-05-26 23:55:14: Reloaded dll
+#2025-05-26 23:56:33[warning]: Couldn't reloaded dll
+#2025-05-26 23:56:35[warning]: Couldn't reloaded dll
+#2025-05-26 23:56:35: Reloaded dll
+#2025-05-26 23:59:17: Destroyed continer: Milk #1
+#2025-05-27 00:01:48[warning]: Couldn't reloaded dll
+#2025-05-27 00:01:50: Reloaded dll
+#2025-05-27 00:01:52: Created container: Milk
+#2025-05-27 00:02:20[warning]: Couldn't reloaded dll
+#2025-05-27 00:02:23: Reloaded dll
+#2025-05-27 00:03:27[warning]: Couldn't reloaded dll
+#2025-05-27 00:03:29[warning]: Couldn't reloaded dll
+#2025-05-27 00:03:30: Reloaded dll
+#2025-05-27 00:04:06[warning]: Couldn't reloaded dll
+#2025-05-27 00:04:08: Reloaded dll
+#2025-05-27 00:05:04[warning]: Couldn't reloaded dll
+#2025-05-27 00:05:06: Reloaded dll
+#2025-05-27 00:05:30[warning]: Couldn't reloaded dll
+#2025-05-27 00:05:32: Reloaded dll
+#2025-05-27 00:06:34[warning]: Couldn't reloaded dll
+#2025-05-27 00:06:36[warning]: Couldn't reloaded dll
+#2025-05-27 00:06:37: Reloaded dll
+#2025-05-27 00:10:01: Destroyed continer: Milk #2

BIN
Pika/resources/milk/bananaGun.png


File diff suppressed because it is too large
+ 0 - 0
Pika/resources/milk/bananagun.bbmodel


BIN
Pika/resources/milk/bananagun.glb


Some files were not shown because too many files changed in this diff