CoriEngine
Loading...
Searching...
No Matches
Cori::Physics Namespace Reference

Anything connected to physics is in this namespace. Please refer to Box2D docs 'https://box2d.org/' for any details regarding physics. More...

Classes

struct  BodyUserData
class  Capsule
struct  CastResult
class  Circle
class  ConvexHull
class  Polygon
class  Segment
struct  ShapeUserData

Typedefs

using Vec2 = b2Vec2
 An alias for Box2D native vec2 type, if you see it somewhere, be sure data there is in meters contrary to when glm used, there data is in camera pixels.
using Rot = b2Rot
using Transform = b2Transform
using CollisionPlane = b2CollisionPlane
using RayResult = b2RayResult

Enumerations

enum  CollisionBits : uint64_t {
  StaticBit = 1ull << 0 , MoverBit = 1ull << 1 , DynamicBit = 1ull << 2 , DebrisBit = 1ull << 3 ,
  SensorBit = 1ull << 4 , CustomBit5 = 1ull << 5 , CustomBit6 = 1ull << 6 , CustomBit7 = 1ull << 7 ,
  CustomBit8 = 1ull << 8 , CustomBit9 = 1ull << 9 , CustomBit10 = 1ull << 10 , CustomBit11 = 1ull << 11 ,
  CustomBit12 = 1ull << 12 , CustomBit13 = 1ull << 13 , CustomBit14 = 1ull << 14 , CustomBit15 = 1ull << 15 ,
  CustomBit16 = 1ull << 16 , CustomBit17 = 1ull << 17 , CustomBit18 = 1ull << 18 , CustomBit19 = 1ull << 19 ,
  CustomBit20 = 1ull << 20 , CustomBit21 = 1ull << 21 , CustomBit22 = 1ull << 22 , CustomBit23 = 1ull << 23 ,
  CustomBit24 = 1ull << 24 , CustomBit25 = 1ull << 25 , CustomBit26 = 1ull << 26 , CustomBit27 = 1ull << 27 ,
  CustomBit28 = 1ull << 28 , CustomBit29 = 1ull << 29 , CustomBit30 = 1ull << 30 , CustomBit31 = 1ull << 31 ,
  CustomBit32 = 1ull << 32 , CustomBit33 = 1ull << 33 , CustomBit34 = 1ull << 34 , CustomBit35 = 1ull << 35 ,
  CustomBit36 = 1ull << 36 , CustomBit37 = 1ull << 37 , CustomBit38 = 1ull << 38 , CustomBit39 = 1ull << 39 ,
  CustomBit40 = 1ull << 40 , CustomBit41 = 1ull << 41 , CustomBit42 = 1ull << 42 , CustomBit43 = 1ull << 43 ,
  CustomBit44 = 1ull << 44 , CustomBit45 = 1ull << 45 , CustomBit46 = 1ull << 46 , CustomBit47 = 1ull << 47 ,
  CustomBit48 = 1ull << 48 , CustomBit49 = 1ull << 49 , CustomBit50 = 1ull << 50 , CustomBit51 = 1ull << 51 ,
  CustomBit52 = 1ull << 52 , CustomBit53 = 1ull << 53 , CustomBit54 = 1ull << 54 , CustomBit55 = 1ull << 55 ,
  CustomBit56 = 1ull << 56 , CustomBit57 = 1ull << 57 , CustomBit58 = 1ull << 58 , CustomBit59 = 1ull << 59 ,
  CustomBit60 = 1ull << 60 , CustomBit61 = 1ull << 61 , CustomBit62 = 1ull << 62 , CustomBit63 = 1ull << 63 ,
  AllBits = ~0u
}
enum class  WindingOrder : uint8_t { COLLINEAR , CLOCKWISE , COUNTER_CLOCKWISE }

Functions

WindingOrder GetPolygonWindingOrder (const std::vector< Vec2 > &polygon)
 Calculates the winding order of the polygon made up from individual points. Box2D version. Takes Box2Ds vec2s.
WindingOrder GetPolygonWindingOrder (const std::vector< tmx::Vector2f > &polygon)
 Calculates the winding order of the polygon made up from individual points. TMXLite version. Takes TMXLite vec2s.
const char * WindingOrderToString (WindingOrder order)
 Converts the WindingOrder enumerator to string, for logging.
glm::vec2 ToPixels (const Vec2 vec)
 Converts physical meters to camera space pixels.
Vec2 ToMeters (const glm::vec2 vec)
 Converts camera space pixels to physical meters.
std::string Vec2ToString (Vec2 vec)
 Converts a native Box2D vec2 to string, for logging.

Detailed Description

Anything connected to physics is in this namespace. Please refer to Box2D docs 'https://box2d.org/' for any details regarding physics.

Cori engine doesn't have a native physics engine and uses Box2D, so refer to Box2D docs 'https://box2d.org/' for any details on physics.
All the engine does is provide a convenient C++ API for it, as Box2D is a C project and the default API is not really convenient in C++ environment.
Big thanks HolyBlackCat for: 'https://github.com/HolyBlackCat/box2cpp/tree/master'

Typedef Documentation

◆ CollisionPlane

using Cori::Physics::CollisionPlane = b2CollisionPlane

Definition at line 45 of file Physics/Physics.hpp.

◆ RayResult

using Cori::Physics::RayResult = b2RayResult

Definition at line 46 of file Physics/Physics.hpp.

◆ Rot

using Cori::Physics::Rot = b2Rot

Definition at line 43 of file Physics/Physics.hpp.

◆ Transform

using Cori::Physics::Transform = b2Transform

Definition at line 44 of file Physics/Physics.hpp.

◆ Vec2

using Cori::Physics::Vec2 = b2Vec2

An alias for Box2D native vec2 type, if you see it somewhere, be sure data there is in meters contrary to when glm used, there data is in camera pixels.

Definition at line 42 of file Physics/Physics.hpp.

Enumeration Type Documentation

◆ CollisionBits

Enumerator
StaticBit 
MoverBit 
DynamicBit 
DebrisBit 
SensorBit 
CustomBit5 
CustomBit6 
CustomBit7 
CustomBit8 
CustomBit9 
CustomBit10 
CustomBit11 
CustomBit12 
CustomBit13 
CustomBit14 
CustomBit15 
CustomBit16 
CustomBit17 
CustomBit18 
CustomBit19 
CustomBit20 
CustomBit21 
CustomBit22 
CustomBit23 
CustomBit24 
CustomBit25 
CustomBit26 
CustomBit27 
CustomBit28 
CustomBit29 
CustomBit30 
CustomBit31 
CustomBit32 
CustomBit33 
CustomBit34 
CustomBit35 
CustomBit36 
CustomBit37 
CustomBit38 
CustomBit39 
CustomBit40 
CustomBit41 
CustomBit42 
CustomBit43 
CustomBit44 
CustomBit45 
CustomBit46 
CustomBit47 
CustomBit48 
CustomBit49 
CustomBit50 
CustomBit51 
CustomBit52 
CustomBit53 
CustomBit54 
CustomBit55 
CustomBit56 
CustomBit57 
CustomBit58 
CustomBit59 
CustomBit60 
CustomBit61 
CustomBit62 
CustomBit63 
AllBits 

Definition at line 49 of file Physics/Physics.hpp.

◆ WindingOrder

enum class Cori::Physics::WindingOrder : uint8_t
strong
Enumerator
COLLINEAR 
CLOCKWISE 
COUNTER_CLOCKWISE 

Definition at line 118 of file Physics/Physics.hpp.

Function Documentation

◆ GetPolygonWindingOrder() [1/2]

WindingOrder Cori::Physics::GetPolygonWindingOrder ( const std::vector< tmx::Vector2f > & polygon)

Calculates the winding order of the polygon made up from individual points. TMXLite version. Takes TMXLite vec2s.

Parameters
polygonPoint that from a polygon.
Returns
A resulting enumerator of type WindingOrder.

Definition at line 30 of file Physics/Physics.cpp.

◆ GetPolygonWindingOrder() [2/2]

WindingOrder Cori::Physics::GetPolygonWindingOrder ( const std::vector< Vec2 > & polygon)

Calculates the winding order of the polygon made up from individual points. Box2D version. Takes Box2Ds vec2s.

Parameters
polygonPoint that from a polygon.
Returns
A resulting enumerator of type WindingOrder.

Definition at line 5 of file Physics/Physics.cpp.

◆ ToMeters()

Vec2 Cori::Physics::ToMeters ( const glm::vec2 vec)

Converts camera space pixels to physical meters.

Parameters
vecPosition in pixels.
Returns
Position in pixels.
Note
Talking about camera space pixels, not screen space/viewport pixels. Uses CORI_PIXELS_PER_METER as a convertion modifier.

Definition at line 74 of file Physics/Physics.cpp.

◆ ToPixels()

glm::vec2 Cori::Physics::ToPixels ( const Vec2 vec)

Converts physical meters to camera space pixels.

Parameters
vecPosition in meters.
Returns
Position in pixels.
Note
Talking about camera space pixels, not screen space/viewport pixels. Uses CORI_PIXELS_PER_METER as a convertion modifier.

Definition at line 70 of file Physics/Physics.cpp.

◆ Vec2ToString()

std::string Cori::Physics::Vec2ToString ( Vec2 vec)

Converts a native Box2D vec2 to string, for logging.

Parameters
vecNative Box2D vec2 to convert to string.
Returns
Formated string.
Note
This is a convenience function and will cause several allocation connected to constructing a string. Be aware.

Definition at line 78 of file Physics/Physics.cpp.

◆ WindingOrderToString()

const char * Cori::Physics::WindingOrderToString ( WindingOrder order)

Converts the WindingOrder enumerator to string, for logging.

Parameters
orderEnumerator.
Returns
Resulting string.

Definition at line 56 of file Physics/Physics.cpp.