Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. struct AABB
  2. {
  3.     glm::vec2 min;
  4.     glm::vec2 max;
  5.  
  6.     AABB::AABB(float minX, float minY, float maxX, float maxY)
  7.     {
  8.         min = glm::vec2(minX, minY);
  9.         max = glm::vec2(maxX, maxY);
  10.     }
  11.  
  12.     int AABB::getHeight()
  13.     {
  14.         return max.y - min.y;
  15.     }
  16.  
  17.     int AABB::getWidth()
  18.     {
  19.         return max.x - min.x;
  20.     }
  21. };
  22.  
  23. //__________________________________
  24.  
  25. PhysObj::PhysObj(float pos_x, float pos_y, float m, int width, int height, float step)
  26.     {
  27.         position = glm::vec2(pos_x, pos_y);
  28.  
  29.         mass.mass = m;
  30.         if (m == 0)
  31.             mass.inv_mass = 0;
  32.         else
  33.             mass.inv_mass = 1 / mass.mass;
  34.  
  35.         square_coll = AABB(pos_x, pos_y, pos_x + width, pos_y + height);
  36.  
  37.         time_step = step;
  38.         original_time = step;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement