physicsTest.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. #pragma once
  2. #include <gl2d/gl2d.h>
  3. #include <imgui.h>
  4. #include <baseContainer.h>
  5. #include <shortcutApi/shortcutApi.h>
  6. #include <pikaSizes.h>
  7. #include <imgui_spinner.h>
  8. #include <ph2d/ph2d.h>
  9. struct PhysicsTest: public Container
  10. {
  11. // Function to generate a pastel color based on an input number
  12. glm::vec3 generatePastelColor(int inputNumber)
  13. {
  14. srand(inputNumber);
  15. // Seed random number generator based on input
  16. //auto baseColor = glm::vec3(0,0,0);
  17. //glm::vec3 baseColor = glm::ballRand<float>(1.0f); // Random direction on a sphere
  18. glm::vec3 baseColor(rand() % 100 / 100.f, rand() % 100 / 100.f, rand() % 100 / 100.f);
  19. baseColor = glm::abs(baseColor); // Ensure positive values
  20. // Adjust saturation to pastel range by mixing with white
  21. float pastelFactor = 0.7f;
  22. glm::vec3 pastelColor = glm::mix(baseColor, glm::vec3(1.0f), pastelFactor);
  23. // Map input number into [0,1] range
  24. float modifier = (inputNumber % 1000) / 1000.0f;
  25. pastelColor += modifier * 0.1f;
  26. return glm::clamp(pastelColor, 0.0f, 1.0f);
  27. }
  28. gl2d::Renderer2D renderer;
  29. ph2d::PhysicsEngine physicsEngine;
  30. gl2d::Texture ballTexture;
  31. std::unordered_set<unsigned int> ropeIds;
  32. //static constexpr float floorPos = 850;
  33. static constexpr float floorPos = 850;
  34. bool simulate = 1;
  35. //todo user can request imgui ids; shortcut manager context; allocators
  36. static ContainerStaticInfo containerInfo()
  37. {
  38. ContainerStaticInfo info = {};
  39. info.defaultHeapMemorySize = pika::MB(10);
  40. info.requestImguiFbo = true;
  41. info.pushAnImguiIdForMe = true;
  42. info.andInputWithWindowHasFocus = 0;
  43. info.andInputWithWindowHasFocusLastFrame = 0;
  44. return info;
  45. }
  46. bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
  47. {
  48. renderer.create(requestedInfo.requestedFBO.fbo);
  49. ballTexture = pika::gl2d::loadTexture(PIKA_RESOURCES_PATH "ball.png", requestedInfo);
  50. physicsEngine.simulationphysicsSettings.gravity = glm::vec2(0, 9.81) * 100.f;
  51. //physicsEngine.simulationphysicsSettings.gravity = glm::vec2(0, 0);
  52. //physicsEngine.simulationphysicsSettings.airDragCoeficient = 0.01f;
  53. //physicsEngine.collisionChecksCount = 1;
  54. for (int i = 0; i < 2; i++)
  55. {
  56. //if (i == 1) { mass = 0; }
  57. if (0)
  58. {
  59. float w = rand() % 100 + 20;
  60. float h = rand() % 100 + 20;
  61. //w = 60;
  62. //h = 60;
  63. auto body = physicsEngine.addBody({rand() % 800 + 100, rand() % 800 + 100},
  64. ph2d::createBoxCollider({w, h}));
  65. //physicsEngine.bodies[body].motionState.rotation = ((rand() % 800) / 800.f) * 3.14159f;
  66. //physicsEngine.bodies[body].flags.setFreezeRotation();
  67. }
  68. for (int j = 0; j < 2; j++)
  69. {
  70. float r = rand() % 35 + 10;
  71. auto body = physicsEngine.addBody({rand() % 800 + 100, rand() % 800 + 100},
  72. ph2d::createCircleCollider({r}));
  73. //physicsEngine.bodies[body].flags.setFreezeRotation();
  74. }
  75. }
  76. if(0)
  77. for (int i = 0; i < 20; i++)
  78. {
  79. float r = 20;
  80. auto body = physicsEngine.addBody(
  81. glm::vec2{300, 200} + glm::vec2{(i % 5) * 40, 0}
  82. + glm::vec2{0,(i / 5) * 40}
  83. +glm::vec2{(i / 5) * 20, 0},
  84. ph2d::createCircleCollider({r}));
  85. }
  86. glm::vec2 shape[5] =
  87. {
  88. {0, -50},
  89. {40, -10},
  90. {25, 25},
  91. {-25, 25},
  92. {-40, -10},
  93. };
  94. for (int i = 0; i < 5; i++) { shape[i] *= 2; }
  95. //rope
  96. if(1)
  97. {
  98. auto bodyA = physicsEngine.addBody({200, 800}, ph2d::createCircleCollider({20}));
  99. physicsEngine.bodies[bodyA].flags.setKinematic(true);
  100. ropeIds.insert(bodyA);
  101. for (int i = 0; i < 25; i++)
  102. {
  103. auto bodyB = physicsEngine.addBody({200 + i * 45, 800}, ph2d::createCircleCollider({20}));
  104. physicsEngine.addConstrain({bodyA, bodyB, 40, 5000 * 1.2});
  105. bodyA = bodyB;
  106. ropeIds.insert(bodyA);
  107. if (i == 24)
  108. {
  109. physicsEngine.bodies[bodyA].flags.setKinematic(true);
  110. }
  111. }
  112. }
  113. //physicsEngine.addBody({500, 200}, ph2d::createConvexPolygonCollider(shape, 5));
  114. if(0)
  115. {
  116. auto b = physicsEngine.addBody({500, 200}, ph2d::createConvexPolygonCollider(shape, 5));
  117. auto body = physicsEngine.addBody({500, 500}, ph2d::createCircleCollider({100}));
  118. auto mass = physicsEngine.bodies[body].motionState.mass;
  119. auto inertia = physicsEngine.bodies[body].motionState.momentOfInertia;
  120. //physicsEngine.bodies[b].flags.setFreezeRotation();
  121. physicsEngine.bodies[b].motionState.mass = mass;
  122. physicsEngine.bodies[b].motionState.momentOfInertia = inertia;
  123. //auto body = physicsEngine.addBody({500, 500}, ph2d::createBoxCollider({200, 200}));
  124. //physicsEngine.bodies[body].flags.setFreezeRotation();
  125. }
  126. {
  127. auto body = physicsEngine.addBody({500, 500}, ph2d::createBoxCollider({200, 200}));
  128. //physicsEngine.bodies[body].flags.setFreezeRotation();
  129. body = physicsEngine.addBody({420, 200}, ph2d::createCircleCollider({50}));
  130. //physicsEngine.bodies[body].flags.setFreezeRotation();
  131. }
  132. //physicsEngine.addBody({500, 1100},
  133. // ph2d::createBoxCollider({1100, 10}));
  134. //physicsEngine.addBody({1, 800}, ph2d::createBoxCollider({300, 250}));
  135. //auto body = physicsEngine.addBody({500, 500}, ph2d::createBoxCollider({400, 50}));
  136. //physicsEngine.bodies[body].flags.setFreezePosition();
  137. //physicsEngine.bodies[body].flags.setFreezeRotation();
  138. //physicsEngine.bodies[1].motionState.mass = 0;
  139. //physicsEngine.bodies[1].motionState.momentOfInertia = 0;
  140. //physicsEngine.addBody({700, 700}, ph2d::createBoxCollider({300, 300}));
  141. //physicsEngine.addBody({600, 600}, ph2d::createBoxCollider({350, 350}));
  142. //physicsEngine.bodies[1].motionState.rotation = glm::radians(30.f);
  143. //physicsEngine.addBody({900, 500}, ph2d::createCircleCollider({40}));
  144. //physicsEngine.addBody({550, 700}, ph2d::createCircleCollider({25}));
  145. //physicsEngine.addBody({600, 600}, ph2d::createBoxCollider({50, 50}));
  146. //std::cout << ph2d::vectorToRotation({0,1}) << "\n";
  147. //std::cout << ph2d::vectorToRotation({-1,1}) << "\n";
  148. //std::cout << ph2d::vectorToRotation({-1,0}) << "\n";
  149. //std::cout << ph2d::vectorToRotation({0,-1}) << "\n";
  150. //std::cout << ph2d::vectorToRotation({1,0}) << "\n";
  151. //
  152. //std::cout << "\n";
  153. //std::cout << ph2d::rotationToVector(ph2d::vectorToRotation({0,1}) ).x << " " << ph2d::rotationToVector(ph2d::vectorToRotation({0,1}) ).y << "\n";
  154. //std::cout << ph2d::rotationToVector(ph2d::vectorToRotation({-1,1})).x << " " << ph2d::rotationToVector(ph2d::vectorToRotation({-1,1})).y << "\n";
  155. //std::cout << ph2d::rotationToVector(ph2d::vectorToRotation({-1,0})).x << " " << ph2d::rotationToVector(ph2d::vectorToRotation({-1,0})).y << "\n";
  156. //std::cout << ph2d::rotationToVector(ph2d::vectorToRotation({0,-1})).x << " " << ph2d::rotationToVector(ph2d::vectorToRotation({0,-1})).y << "\n";
  157. //std::cout << ph2d::rotationToVector(ph2d::vectorToRotation({1,0}) ).x << " " << ph2d::rotationToVector(ph2d::vectorToRotation({1,0}) ).y << "\n";
  158. //auto b = physicsEngine.addHalfSpaceStaticObject({0, floorPos + 10}, {0.0, 1});
  159. //physicsEngine.bodies[b].staticFriction = 0;
  160. //physicsEngine.bodies[b].dynamicFriction = 0;
  161. //physicsEngine.addBody({500, floorPos}, ph2d::createBoxCollider({900, 50}));
  162. //physicsEngine.bodies.back().motionState.mass = 0;
  163. //physicsEngine.bodies.back().motionState.momentOfInertia = 0;
  164. return true;
  165. }
  166. bool update(pika::Input input, pika::WindowState windowState,
  167. RequestedContainerInfo &requestedInfo)
  168. {
  169. #pragma region init stuff
  170. int w = 0; int h = 0;
  171. w = windowState.frameBufferW; //window w
  172. h = windowState.frameBufferH; //window h
  173. glClearColor(0.2, 0.22, 0.23, 1);
  174. glClear(GL_COLOR_BUFFER_BIT); //clear screen
  175. renderer.updateWindowMetrics(w, h);
  176. #pragma endregion
  177. //ph2d::AABB box1 = glm::vec4{300,300, 300,300};
  178. //
  179. //ph2d::AABB box2 = glm::vec4(glm::vec2(platform::getRelMousePosition()) - glm::vec2(50, 50), 100, 100);
  180. //
  181. //renderer.renderRectangleOutline(box1.asVec4(), Colors_White);
  182. //
  183. //auto color = Colors_White;
  184. //
  185. //if (ph2d::AABBvsAABB(box1, box2))
  186. //{
  187. // color = Colors_Red;
  188. //}
  189. //
  190. //renderer.renderRectangleOutline(box2.asVec4(), color);
  191. //ph2d::Circle a = glm::vec3{450,450, 150};
  192. //ph2d::Circle b = glm::vec3(glm::vec2(platform::getRelMousePosition()), 50);
  193. //renderer.renderCircleOutline(a.center, a.r, Colors_White, 2, 32);
  194. //
  195. //auto color = Colors_White;
  196. //if (ph2d::CirclevsCircle(a, b))
  197. //{
  198. // color = Colors_Red;
  199. //}
  200. //renderer.renderCircleOutline(b.center, b.r, color, 2, 32);
  201. static int simulationSpeed = 1;
  202. float rightPos = 1200;
  203. //physicsEngine.bodies[0].motionState.rotation = glm::radians(-30.f);
  204. ImGui::PushStyleColor(ImGuiCol_WindowBg, {0.3,0.3,0.3,0.8});
  205. ImGui::Begin("Settings");
  206. ImGui::DragInt("Speed", &simulationSpeed);
  207. ImGui::SliderAngle("Angle", &physicsEngine.bodies[1].motionState.rotation);
  208. ImGui::SliderAngle("angular velocity", &physicsEngine.bodies[1].motionState.angularVelocity);
  209. //physicsEngine.bodies[0].motionState.angularVelocity = 1.5;
  210. ImGui::Text("Mouse pos %d, %d", input.mouseX, input.mouseY);
  211. ImGui::Text("Y min pos %f", physicsEngine.bodies[1].getAABB().min().y);
  212. ImGui::Text("Moment of inertia %f", physicsEngine.bodies[1].motionState.momentOfInertia);
  213. ImGui::Checkbox("Simulate", &simulate);
  214. ImGui::End();
  215. ImGui::PopStyleColor();
  216. static int selected = -1;
  217. //mouse
  218. if (!simulate && input.rMouse.held())
  219. {
  220. physicsEngine.bodies[1].motionState.setPos({input.mouseX, input.mouseY});
  221. }
  222. static glm::vec2 pressedPosition = {};
  223. if (input.lMouse.pressed())
  224. {
  225. selected = -1;
  226. for (auto b : physicsEngine.bodies)
  227. {
  228. if (b.second.intersectPoint({input.mouseX, input.mouseY}))
  229. {
  230. selected = b.first;
  231. pressedPosition = {input.mouseX, input.mouseY};
  232. }
  233. }
  234. }
  235. if (selected > 0)
  236. {
  237. renderer.renderLine(pressedPosition, {input.mouseX, input.mouseY}, Colors_Blue, 4);
  238. }
  239. if (input.lMouse.released() && selected > 0)
  240. {
  241. glm::vec2 force = pressedPosition - glm::vec2({input.mouseX, input.mouseY});
  242. //physicsEngine.bodies[selected].motionState.velocity += force;
  243. force *= physicsEngine.bodies[selected].motionState.mass;
  244. force *= 4.f;
  245. physicsEngine.bodies[selected].applyImpulseWorldPosition(force,
  246. //physicsEngine.bodies[selected].motionState.pos
  247. pressedPosition
  248. );
  249. //physicsEngine.bodies[selected].motionState.angularVelocity = 10;
  250. selected = -1;
  251. pressedPosition = {};
  252. }
  253. for (int i = 0; i < simulationSpeed; i++)
  254. {
  255. //gravity
  256. //if(simulate)
  257. //for (int i=0; i<physicsEngine.bodies.size(); i++)
  258. //{
  259. // if(physicsEngine.bodies[i].motionState.mass != 0 && physicsEngine.bodies[i].motionState.mass != INFINITY)
  260. // physicsEngine.bodies[i].motionState.acceleration += glm::vec2(0, 9.81) * 100.f;
  261. //}
  262. if (simulate)
  263. {
  264. physicsEngine.collisionChecksCount = 8;
  265. physicsEngine.setFixedTimeStamp = 0;
  266. physicsEngine.runSimulation(input.deltaTime);
  267. }
  268. else
  269. {
  270. physicsEngine.collisionChecksCount = 0;
  271. physicsEngine.runSimulation(0);
  272. }
  273. for (auto &it : physicsEngine.bodies)
  274. {
  275. auto &b = it.second;
  276. auto bottom = b.getAABB().max().y;
  277. auto left = b.getAABB().min().x;
  278. auto right = b.getAABB().max().x;
  279. auto top = b.getAABB().min().y;
  280. //if (bottom > floorPos)
  281. //{
  282. // float diff = bottom - floorPos;
  283. // b.motionState.pos.y -= diff;
  284. // b.motionState.lastPos = b.motionState.pos;
  285. //
  286. // b.motionState.velocity.y *= -0.2;
  287. //}
  288. if (left < 0)
  289. {
  290. b.motionState.pos.x -= left;
  291. b.motionState.lastPos = b.motionState.pos;
  292. b.motionState.velocity.x *= -1;
  293. }
  294. if (right > rightPos)
  295. {
  296. b.motionState.pos.x -= right - rightPos;
  297. b.motionState.lastPos = b.motionState.pos;
  298. b.motionState.velocity.x *= -1;
  299. }
  300. if (top < 0)
  301. {
  302. b.motionState.pos.y -= top;
  303. b.motionState.lastPos = b.motionState.pos;
  304. b.motionState.velocity.y *= -1;
  305. }
  306. }
  307. }
  308. //std::cout << physicsEngine.bodies[0].getAABB().max().x << "\n";
  309. //renderer.renderRectangleOutline({300 - 25, 100 - 25, 50, 50}, Colors_Red);
  310. //renderer.renderRectangleOutline({600 - 25, 200 - 25, 50, 50}, Colors_Red);
  311. float p = 0;
  312. glm::vec2 n = {};
  313. bool penetrated = 0;
  314. glm::vec2 contactPoint = {};
  315. glm::vec2 tangentA = {};
  316. glm::vec2 tangentB = {};
  317. if (ph2d::BodyvsBody(physicsEngine.bodies[1],
  318. physicsEngine.bodies[2],
  319. p, n, contactPoint, tangentA, tangentB))
  320. {
  321. penetrated = true;
  322. }
  323. //auto a = physicsEngine.bodies[0].getAABB();
  324. //auto b = physicsEngine.bodies[1].getAABB();
  325. //ph2d::Circle a1 = glm::vec3{a.center(),a.size.x / 2};
  326. //ph2d::Circle b1 = glm::vec3{b.center(),b.size.x / 2};
  327. //if (ph2d::CirclevsCircle(a1, b1, p, n, contactPoint))
  328. //{
  329. // penetrated = true;
  330. //}
  331. //auto a = physicsEngine.bodies[0].getAABB();
  332. //auto b = physicsEngine.bodies[1];
  333. //ph2d::LineEquation lineEquation;
  334. //lineEquation.createFromRotationAndPoint(b.motionState.rotation,
  335. // b.motionState.pos);
  336. //if (ph2d::HalfSpaceVSCircle(lineEquation, a, p, n, contactPoint))
  337. //{
  338. // penetrated = true;
  339. //}
  340. //glm::vec2 cornersA[4] = {};
  341. //glm::vec2 cornersB[4] = {};
  342. //physicsEngine.bodies[0].getAABB().getCornersRotated(cornersA, physicsEngine.bodies[0].motionState.rotation);
  343. //physicsEngine.bodies[1].getAABB().getCornersRotated(cornersB, physicsEngine.bodies[1].motionState.rotation);
  344. //
  345. //float rez = ph2d::calculatePenetrationAlongOneAxe(cornersA, 4, cornersB, 4, {1,0});
  346. //if (rez > 0)
  347. //{
  348. // penetrated = true;
  349. //}
  350. ImGui::Begin("Settings");
  351. ImGui::Text("Penetration: %f", p);
  352. ImGui::End();
  353. if (input.buttons[pika::Button::P].held())
  354. {
  355. static float timer = 0;
  356. static float counter = 0;
  357. if (timer <= 0)
  358. {
  359. auto p = physicsEngine.addBody({input.mouseX, input.mouseY}, ph2d::createCircleCollider({22}));
  360. glm::vec2 direction = {sin(counter), cos(counter)};
  361. direction.y = std::abs(direction.y);
  362. direction.y += 0.1;
  363. direction = glm::normalize(direction);
  364. physicsEngine.bodies[p].motionState.velocity = direction * 200.f;
  365. timer = 0.2;
  366. };
  367. timer -= input.deltaTime;
  368. counter += input.deltaTime * 2.f;
  369. }
  370. for (auto &i : physicsEngine.bodies)
  371. {
  372. auto &b = i.second;
  373. auto color = glm::vec4(generatePastelColor(i.first), 1);
  374. if (i.first == selected)
  375. {
  376. color = Colors_Blue;
  377. }
  378. if (b.intersectPoint({input.mouseX, input.mouseY}))
  379. {
  380. color = Colors_Turqoise;
  381. }
  382. //if (penetrated)
  383. //{
  384. // color = Colors_Red;
  385. //}
  386. //if (OBBvsPoint(physicsEngine.bodies[i].getAABB(),
  387. // physicsEngine.bodies[i].motionState.rotation,
  388. // {input.mouseX, input.mouseY}))
  389. //{
  390. // color = Colors_Blue;
  391. //}
  392. if (b.collider.type == ph2d::ColliderCircle)
  393. {
  394. renderer.renderCircleOutline(b.motionState.pos,
  395. b.collider.collider.circle.radius, color, 2, 32);
  396. glm::vec2 vector = {1,0};
  397. vector = ph2d::rotateAroundCenter(vector, b.motionState.rotation);
  398. renderer.renderLine(b.motionState.pos, b.motionState.pos + vector *
  399. b.collider.collider.circle.radius, color, 4);
  400. auto color = Colors_White;
  401. if (ropeIds.find(i.first) == ropeIds.end())
  402. {
  403. color = glm::vec4(generatePastelColor(i.first), 1);
  404. }
  405. renderer.renderRectangle(b.getAABB().asVec4(), ballTexture, color, {}, b.motionState.rotation);
  406. }
  407. else if (b.collider.type == ph2d::ColliderBox)
  408. {
  409. float rotation = glm::degrees(b.motionState.rotation);
  410. renderer.renderRectangleOutline(b.getAABB().asVec4(), color, 2, {}, rotation);
  411. }
  412. else if (b.collider.type == ph2d::ColliderHalfSpace)
  413. {
  414. ph2d::LineEquation lineEquation;
  415. lineEquation.createFromRotationAndPoint(b.motionState.rotation,
  416. b.motionState.pos);
  417. glm::vec2 lineEquationStart = lineEquation.getClosestPointToOrigin();
  418. lineEquationStart -= lineEquation.getLineVector() * 1000.f;
  419. renderer.renderLine(lineEquationStart, lineEquationStart + lineEquation.getLineVector() * 2000.f, Colors_Red, 4);
  420. }
  421. else if (b.collider.type == ph2d::ColliderConvexPolygon)
  422. {
  423. auto &c = b.collider.collider.convexPolygon;
  424. for (int i = 0; i < c.vertexCount; i++)
  425. {
  426. glm::vec2 p1 = c.vertexesObjectSpace[i] + b.motionState.pos;
  427. glm::vec2 p2 = c.vertexesObjectSpace[(i + 1) % c.vertexCount] + b.motionState.pos;
  428. p1 = ph2d::rotateAroundPoint(p1, b.motionState.pos, b.motionState.rotation);
  429. p2 = ph2d::rotateAroundPoint(p2, b.motionState.pos, b.motionState.rotation);
  430. renderer.renderLine(p1, p2, color, 4);
  431. }
  432. }
  433. }
  434. //renderer.renderRectangle({-100, floorPos, 100000, 20});
  435. if (penetrated)
  436. {
  437. renderer.renderLine(contactPoint,
  438. contactPoint + n * 100.f, Colors_Green, 4);
  439. renderer.renderRectangle({contactPoint - glm::vec2(2,2), 4,4}, Colors_White);
  440. //renderer.renderLine(contactPoint,
  441. // contactPoint + tangentA * 100.f, Colors_Red, 4);
  442. //renderer.renderLine(contactPoint,
  443. // contactPoint + tangentB * 100.f, Colors_Purple, 4);
  444. }
  445. renderer.renderRectangle({
  446. glm::vec2(input.mouseX,input.mouseY) - glm::vec2(4,4), 8, 8}, Colors_Red);
  447. //glm::vec2 lineEquationStart = lineEquation.getClosestPointToOrigin();
  448. //lineEquationStart -= lineEquation.getLineVector() * 1000.f;
  449. //renderer.renderLine(lineEquationStart, lineEquationStart + lineEquation.getLineVector() * 2000.f, Colors_Red);
  450. //ph2d::LineEquation lineEquation;
  451. //lineEquation.createFromNormalAndPoint({0,1}, {0, floorPos});
  452. //float pl = 0;
  453. //pl = lineEquation.computeEquation(platform::getRelMousePosition());
  454. //ImGui::Begin("Settings");
  455. //ImGui::Text("Penetration line: %f", pl);
  456. //ImGui::End();
  457. //glm::vec2 p2 = platform::getRelMousePosition();
  458. //p2 = ph2d::rotateAroundCenter(p2, glm::radians(45.f));
  459. //renderer.renderRectangle({p2, 10, 10}, Colors_Red);
  460. renderer.flush();
  461. return true;
  462. }
  463. //optional
  464. void destruct(RequestedContainerInfo &requestedInfo)
  465. {
  466. }
  467. };