载入中...
搜索中...
未找到
eve::physics::World类 参考

Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity, raycasts, AABB queries and contact/impact events. 更多...

#include <World.h>

struct  ContactEvent
 
struct  ImpactEvent
 

Public 成员函数

 World (float gravityX, float gravityY, bool sleep, float meter)
 Creates a physics world.
 
 ~World ()
 
 World (const World &)=delete
 
Worldoperator= (const World &)=delete
 
void update (float dt)
 Steps the simulation by dt seconds (5 velocity / 2 position iterations).
 
void updateFull (float dt, int velocityIterations, int positionIterations)
 Steps with explicit iteration counts.
 
void setGravity (float gx, float gy)
 Sets the world gravity vector in pixels/s^2.
 
float getGravityX () const
 
float getGravityY () const
 
void setMeter (float pixelsPerMeter)
 Changes the pixels-per-meter conversion.
 
float getMeter () const
 
BodynewBody (const std::string &bodyType, float x, float y)
 bodyType: "static" | "kinematic" | "dynamic". x/y in pixels.
 
void destroyBody (Body *body)
 Destroys a body (null is ignored).
 
void destroy ()
 Destroys the underlying Box2D world and resets event buffers.
 
void drawDebug (graphics::Graphics *gfx)
 Optional: draw fixture AABBs via Graphics::drawSolidRect.
 
int rayCast (float x1, float y1, float x2, float y2)
 Closest raycast in pixel space from (x1,y1) to (x2,y2). Returns hit body id, or -1. Read hit details via getRayHit*.
 
bool hasRayHit () const
 
int getRayHitBodyId () const
 
float getRayHitX () const
 
float getRayHitY () const
 
float getRayHitNormalX () const
 
float getRayHitNormalY () const
 
float getRayHitFraction () const
 Fraction along the segment [0,1] of the closest hit.
 
int queryAABB (float x, float y, float w, float h)
 Query fixtures overlapping an axis-aligned box in pixel space (x,y,w,h). Returns match count; read ids with getQueryBodyId(i).
 
int getQueryCount () const
 
int getQueryBodyId (int index) const
 
int getBeginContactCount () const
 
int getBeginContactBodyAId (int index) const
 
int getBeginContactBodyBId (int index) const
 
std::string getBeginContactFixtureATag (int index) const
 
std::string getBeginContactFixtureBTag (int index) const
 
int getEndContactCount () const
 
int getEndContactBodyAId (int index) const
 
int getEndContactBodyBId (int index) const
 
std::string getEndContactFixtureATag (int index) const
 
std::string getEndContactFixtureBTag (int index) const
 
int getImpactCount () const
 
int getImpactBodyAId (int index) const
 
int getImpactBodyBId (int index) const
 
std::string getImpactFixtureATag (int index) const
 
std::string getImpactFixtureBTag (int index) const
 
float getImpactPointX (int index) const
 
float getImpactPointY (int index) const
 
float getImpactNormalX (int index) const
 
float getImpactNormalY (int index) const
 
float getImpactRelativeNormalSpeed (int index) const
 
float getImpactNormalImpulse (int index) const
 
float getImpactTangentImpulse (int index) const
 
void clearContactEvents ()
 Clears collected begin/end contact and impact event buffers.
 
float toMeters (float pixels) const
 Converts a pixel-space length to meters.
 
float toPixels (float meters) const
 Converts a meter-space length to pixels.
 
b2World * raw ()
 The underlying Box2D world (advanced use).
 
const b2World * raw () const
 
void onBeginContact (b2Contact *contact)
 
void onEndContact (b2Contact *contact)
 
void onPreSolve (b2Contact *contact, const b2Manifold *oldManifold)
 
void onPostSolve (b2Contact *contact, const b2ContactImpulse *impulse)
 
void forgetBody (Body *body)
 
void forgetFixture (Fixture *fixture)
 
int nextBodyId ()
 

友元

class Body
 
class Fixture
 

详细描述

Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity, raycasts, AABB queries and contact/impact events.

在文件 World.h31 行定义.

构造及析构函数说明

◆ World() [1/2]

eve::physics::World::World ( float  gravityX,
float  gravityY,
bool  sleep,
float  meter 
)

Creates a physics world.

参数
gravityX/gravityYGravity vector in pixels/s^2.
sleepWhether bodies may sleep when idle.
meterPixels per meter conversion factor.

在文件 World.cpp147 行定义.

引用了 toMeters().

◆ ~World()

eve::physics::World::~World ( )

在文件 World.cpp157 行定义.

引用了 destroy().

◆ World() [2/2]

eve::physics::World::World ( const World )
delete

成员函数说明

◆ clearContactEvents()

void eve::physics::World::clearContactEvents ( )

Clears collected begin/end contact and impact event buffers.

在文件 World.cpp425 行定义.

被这些函数引用 destroy().

◆ destroy()

void eve::physics::World::destroy ( )

Destroys the underlying Box2D world and resets event buffers.

在文件 World.cpp159 行定义.

引用了 b, clearContactEvents() , 以及 f.

被这些函数引用 ~World().

◆ destroyBody()

void eve::physics::World::destroyBody ( Body body)

Destroys a body (null is ignored).

在文件 World.cpp244 行定义.

引用了 body.

◆ drawDebug()

void eve::physics::World::drawDebug ( graphics::Graphics gfx)

Optional: draw fixture AABBs via Graphics::drawSolidRect.

在文件 World.cpp432 行定义.

引用了 eve::physics::DebugDraw::begin() , 以及 eve::physics::DebugDraw::end().

◆ forgetBody()

void eve::physics::World::forgetBody ( Body body)

在文件 World.cpp249 行定义.

引用了 body , 以及 id.

被这些函数引用 eve::physics::Body::destroy() , 以及 eve::physics::Body::~Body().

◆ forgetFixture()

◆ getBeginContactBodyAId()

int eve::physics::World::getBeginContactBodyAId ( int  index) const

在文件 World.cpp367 行定义.

◆ getBeginContactBodyBId()

int eve::physics::World::getBeginContactBodyBId ( int  index) const

在文件 World.cpp370 行定义.

◆ getBeginContactCount()

int eve::physics::World::getBeginContactCount ( ) const
inline

在文件 World.h108 行定义.

◆ getBeginContactFixtureATag()

std::string eve::physics::World::getBeginContactFixtureATag ( int  index) const

在文件 World.cpp373 行定义.

◆ getBeginContactFixtureBTag()

std::string eve::physics::World::getBeginContactFixtureBTag ( int  index) const

在文件 World.cpp376 行定义.

◆ getEndContactBodyAId()

int eve::physics::World::getEndContactBodyAId ( int  index) const

在文件 World.cpp379 行定义.

◆ getEndContactBodyBId()

int eve::physics::World::getEndContactBodyBId ( int  index) const

在文件 World.cpp382 行定义.

◆ getEndContactCount()

int eve::physics::World::getEndContactCount ( ) const
inline

在文件 World.h113 行定义.

◆ getEndContactFixtureATag()

std::string eve::physics::World::getEndContactFixtureATag ( int  index) const

在文件 World.cpp385 行定义.

◆ getEndContactFixtureBTag()

std::string eve::physics::World::getEndContactFixtureBTag ( int  index) const

在文件 World.cpp388 行定义.

◆ getGravityX()

float eve::physics::World::getGravityX ( ) const

在文件 World.cpp209 行定义.

引用了 toPixels().

◆ getGravityY()

float eve::physics::World::getGravityY ( ) const

在文件 World.cpp214 行定义.

引用了 toPixels().

◆ getImpactBodyAId()

int eve::physics::World::getImpactBodyAId ( int  index) const

在文件 World.cpp391 行定义.

◆ getImpactBodyBId()

int eve::physics::World::getImpactBodyBId ( int  index) const

在文件 World.cpp394 行定义.

◆ getImpactCount()

int eve::physics::World::getImpactCount ( ) const
inline

在文件 World.h119 行定义.

◆ getImpactFixtureATag()

std::string eve::physics::World::getImpactFixtureATag ( int  index) const

在文件 World.cpp397 行定义.

◆ getImpactFixtureBTag()

std::string eve::physics::World::getImpactFixtureBTag ( int  index) const

在文件 World.cpp400 行定义.

◆ getImpactNormalImpulse()

float eve::physics::World::getImpactNormalImpulse ( int  index) const

在文件 World.cpp418 行定义.

◆ getImpactNormalX()

float eve::physics::World::getImpactNormalX ( int  index) const

在文件 World.cpp409 行定义.

◆ getImpactNormalY()

float eve::physics::World::getImpactNormalY ( int  index) const

在文件 World.cpp412 行定义.

◆ getImpactPointX()

float eve::physics::World::getImpactPointX ( int  index) const

在文件 World.cpp403 行定义.

◆ getImpactPointY()

float eve::physics::World::getImpactPointY ( int  index) const

在文件 World.cpp406 行定义.

◆ getImpactRelativeNormalSpeed()

float eve::physics::World::getImpactRelativeNormalSpeed ( int  index) const

在文件 World.cpp415 行定义.

◆ getImpactTangentImpulse()

float eve::physics::World::getImpactTangentImpulse ( int  index) const

在文件 World.cpp421 行定义.

◆ getMeter()

float eve::physics::World::getMeter ( ) const
inline

在文件 World.h73 行定义.

◆ getQueryBodyId()

int eve::physics::World::getQueryBodyId ( int  index) const

在文件 World.cpp515 行定义.

◆ getQueryCount()

int eve::physics::World::getQueryCount ( ) const
inline

在文件 World.h105 行定义.

◆ getRayHitBodyId()

int eve::physics::World::getRayHitBodyId ( ) const
inline

在文件 World.h92 行定义.

◆ getRayHitFraction()

float eve::physics::World::getRayHitFraction ( ) const
inline

Fraction along the segment [0,1] of the closest hit.

在文件 World.h98 行定义.

◆ getRayHitNormalX()

float eve::physics::World::getRayHitNormalX ( ) const
inline

在文件 World.h95 行定义.

◆ getRayHitNormalY()

float eve::physics::World::getRayHitNormalY ( ) const
inline

在文件 World.h96 行定义.

◆ getRayHitX()

float eve::physics::World::getRayHitX ( ) const
inline

在文件 World.h93 行定义.

◆ getRayHitY()

float eve::physics::World::getRayHitY ( ) const
inline

在文件 World.h94 行定义.

◆ hasRayHit()

bool eve::physics::World::hasRayHit ( ) const
inline

在文件 World.h91 行定义.

◆ newBody()

Body * eve::physics::World::newBody ( const std::string &  bodyType,
float  x,
float  y 
)

bodyType: "static" | "kinematic" | "dynamic". x/y in pixels.

在文件 World.cpp230 行定义.

引用了 Body, body, nextBodyId(), raw(), toMeters(), x , 以及 y.

◆ nextBodyId()

int eve::physics::World::nextBodyId ( )

在文件 World.cpp228 行定义.

被这些函数引用 newBody().

◆ onBeginContact()

void eve::physics::World::onBeginContact ( b2Contact *  contact)

在文件 World.cpp284 行定义.

引用了 a, b , 以及 eve::event::Variant::makeInt().

被这些函数引用 eve::physics::ContactRelay::BeginContact().

◆ onEndContact()

void eve::physics::World::onEndContact ( b2Contact *  contact)

在文件 World.cpp300 行定义.

引用了 a, b , 以及 eve::event::Variant::makeInt().

被这些函数引用 eve::physics::ContactRelay::EndContact().

◆ onPostSolve()

◆ onPreSolve()

void eve::physics::World::onPreSolve ( b2Contact *  contact,
const b2Manifold *  oldManifold 
)

在文件 World.cpp317 行定义.

引用了 a, b, data , 以及 toPixels().

被这些函数引用 eve::physics::ContactRelay::PreSolve().

◆ operator=()

World & eve::physics::World::operator= ( const World )
delete

◆ queryAABB()

int eve::physics::World::queryAABB ( float  x,
float  y,
float  w,
float  h 
)

Query fixtures overlapping an axis-aligned box in pixel space (x,y,w,h). Returns match count; read ids with getQueryBodyId(i).

在文件 World.cpp484 行定义.

引用了 b, h, toMeters(), w, x , 以及 y.

◆ raw() [1/2]

b2World * eve::physics::World::raw ( )
inline

The underlying Box2D world (advanced use).

在文件 World.h140 行定义.

被这些函数引用 eve::physics::Body::destroy(), forgetFixture(), newBody() , 以及 eve::physics::Body::~Body().

◆ raw() [2/2]

const b2World * eve::physics::World::raw ( ) const
inline

在文件 World.h141 行定义.

◆ rayCast()

int eve::physics::World::rayCast ( float  x1,
float  y1,
float  x2,
float  y2 
)

Closest raycast in pixel space from (x1,y1) to (x2,y2). Returns hit body id, or -1. Read hit details via getRayHit*.

在文件 World.cpp439 行定义.

引用了 b, normal, toMeters() , 以及 toPixels().

◆ setGravity()

void eve::physics::World::setGravity ( float  gx,
float  gy 
)

Sets the world gravity vector in pixels/s^2.

在文件 World.cpp204 行定义.

引用了 toMeters().

◆ setMeter()

void eve::physics::World::setMeter ( float  pixelsPerMeter)

Changes the pixels-per-meter conversion.

在文件 World.cpp219 行定义.

◆ toMeters()

◆ toPixels()

◆ update()

void eve::physics::World::update ( float  dt)

Steps the simulation by dt seconds (5 velocity / 2 position iterations).

在文件 World.cpp194 行定义.

引用了 updateFull().

◆ updateFull()

void eve::physics::World::updateFull ( float  dt,
int  velocityIterations,
int  positionIterations 
)

Steps with explicit iteration counts.

在文件 World.cpp196 行定义.

被这些函数引用 update().

友元及相关函数文档

◆ Body

friend class Body
friend

在文件 World.h154 行定义.

被这些函数引用 newBody().

◆ Fixture

friend class Fixture
friend

在文件 World.h155 行定义.


该类的文档由以下文件生成: