Magic_Game/src/kiwano-physics/Body.h

381 lines
10 KiB
C
Raw Normal View History

2019-10-18 11:50:46 +08:00
// Copyright (c) 2018-2019 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include <kiwano-physics/helper.h>
#include <kiwano-physics/Shape.h>
2019-10-22 16:49:34 +08:00
#include <kiwano-physics/Fixture.h>
2019-10-31 20:34:38 +08:00
#include <kiwano-physics/Contact.h>
2019-10-18 11:50:46 +08:00
namespace kiwano
{
namespace physics
{
2019-11-06 16:29:36 +08:00
class World;
2019-10-18 11:50:46 +08:00
2019-11-06 16:29:36 +08:00
KGE_DECLARE_SMART_PTR(Body);
2019-12-31 16:01:41 +08:00
/**
* \addtogroup Physics
* @{
*/
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD>
2019-11-06 16:29:36 +08:00
class KGE_API Body
2019-10-30 23:12:18 +08:00
: public virtual RefCounter
2019-10-18 11:50:46 +08:00
{
public:
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-18 11:50:46 +08:00
enum class Type
{
2019-12-31 16:01:41 +08:00
Static = 0, ///< <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
Kinematic, ///< <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>
Dynamic, ///< <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
2019-10-18 11:50:46 +08:00
};
2019-11-06 16:29:36 +08:00
Body();
Body(b2Body* body, Actor* actor);
Body(World* world, Actor* actor);
2019-12-31 16:01:41 +08:00
Body(World* world, ActorPtr actor);
2019-11-06 16:29:36 +08:00
virtual ~Body();
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ʼ<EFBFBD><CABC>
/// @param[in] world <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// @param[in] actor <20>󶨵Ľ<F3B6A8B5>ɫ
2019-11-06 16:29:36 +08:00
void Init(World* world, Actor* actor);
2019-10-23 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD>Ӽо<D3BC>
/// @param shape <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddFixture(Shape* shape, const Fixture::Param& param);
2019-11-01 16:23:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>μо<CEBC>
/// @param radius Բ<>ΰ뾶
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddCircleShape(float radius, float density = 0.f);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD>Ӻ<EFBFBD><D3BA>μо<CEBC>
/// @param size <20>д<EFBFBD>С
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddBoxShape(Vec2 const& size, float density = 0.f);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>μо<CEBC>
/// @param vertexs <20><><EFBFBD><EFBFBD><EFBFBD>ζ˵<CEB6>
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddPolygonShape(Vector<Point> const& vertexs, float density = 0.f);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><DFB6>μо<CEBC>
/// @param p1 <20>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD>
/// @param p2 <20>߶<EFBFBD><DFB6>յ<EFBFBD>
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddEdgeShape(Point const& p1, Point const& p2, float density = 0.f);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μо<CEBC>
/// @param vertexs <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
/// @param loop <20>Ƿ<EFBFBD><C7B7>պ<EFBFBD>
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
2019-11-06 16:29:36 +08:00
Fixture AddChainShape(Vector<Point> const& vertexs, bool loop, float density = 0.f);
2019-10-22 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD>о<EFBFBD><D0BE>б<EFBFBD>
FixtureList GetFixtureList() const;
2019-10-22 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20>Ƴ<EFBFBD><C6B3>о<EFBFBD>
2019-11-06 16:29:36 +08:00
void RemoveFixture(Fixture const& fixture);
2019-10-22 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD>б<EFBFBD>
ContactEdgeList GetContactList() const;
2019-10-31 20:34:38 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint16_t GetCategoryBits() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-31 20:34:38 +08:00
void SetCategoryBits(uint16_t category_bits);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>
uint16_t GetMaskBits() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>
2019-10-31 20:34:38 +08:00
void SetMaskBits(uint16_t mask_bits);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int16_t GetGroupIndex() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-31 20:34:38 +08:00
void SetGroupIndex(int16_t index);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1>ת<EFBFBD>Ƕ<EFBFBD>
float GetBodyRotation() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
void SetBodyRotation(float angle);
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2019-10-30 23:12:18 +08:00
Point GetBodyPosition() const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
void SetBodyPosition(Point const& pos);
/// \~chinese
/// @brief λ<>ú<EFBFBD><C3BA><EFBFBD>ת<EFBFBD>
2019-10-30 23:12:18 +08:00
void SetBodyTransform(Point const& pos, float angle);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> [kg]
float GetMass() const;
2019-10-22 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
float GetInertia() const;
2019-10-28 17:25:06 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// @param[out] mass <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [kg]
/// @param[out] center <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
/// @param[out] inertia <20><><EFBFBD><EFBFBD>
2019-11-01 16:23:46 +08:00
void GetMassData(float* mass, Point* center, float* inertia) const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// @param mass <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [kg]
/// @param center <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
/// @param inertia <20><><EFBFBD><EFBFBD>
2019-10-30 23:12:18 +08:00
void SetMassData(float mass, Point const& center, float inertia);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-30 23:12:18 +08:00
void ResetMassData();
2019-10-28 17:25:06 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>λ<EFBFBD><CEBB>
2019-10-22 16:49:34 +08:00
Point GetLocalPoint(Point const& world) const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>λ<EFBFBD><CEBB>
2019-10-22 16:49:34 +08:00
Point GetWorldPoint(Point const& local) const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2019-10-30 23:12:18 +08:00
Point GetLocalCenter() const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2019-10-30 23:12:18 +08:00
Point GetWorldCenter() const;
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Type GetType() const;
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetType(Type type);
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
float GetGravityScale() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
void SetGravityScale(float scale);
/// \~chinese
/// @brief ʩ<><CAA9>
/// @param force <20><><EFBFBD>Ĵ<EFBFBD>С<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
/// @param point ʩ<><CAA9><EFBFBD><EFBFBD>
/// @param wake <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-23 16:49:34 +08:00
void ApplyForce(Vec2 const& force, Point const& point, bool wake = true);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9>
/// @param force <20><><EFBFBD>Ĵ<EFBFBD>С<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
/// @param wake <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-23 16:49:34 +08:00
void ApplyForceToCenter(Vec2 const& force, bool wake = true);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief ʩ<><CAA9>Ť<EFBFBD><C5A4>
/// @param torque Ť<><C5A4>
/// @param wake <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ApplyTorque(float torque, bool wake = false);
2019-10-23 16:49:34 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ת<EFBFBD>Ƕ<EFBFBD><C7B6>Ƿ<EFBFBD><C7B7>̶<EFBFBD>
bool IsIgnoreRotation() const;
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>̶<EFBFBD><CCB6><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
void SetIgnoreRotation(bool flag);
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
bool IsBullet() const;
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
void SetBullet(bool flag);
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD>״̬
bool IsAwake() const;
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>״̬
void SetAwake(bool flag);
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool IsSleepingAllowed() const;
2019-10-30 23:12:18 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetSleepingAllowed(bool flag);
/// \~chinese
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
bool IsActive() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
void SetActive(bool flag);
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
World* GetWorld() const;
2019-10-18 11:50:46 +08:00
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>󶨵Ľ<F3B6A8B5>ɫ
Actor* GetActor() const;
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󶨵Ľ<F3B6A8B5>ɫ
void SetActor(Actor* actor);
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>ɫ
2019-10-18 11:50:46 +08:00
void UpdateActor();
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>Ϣ<EFBFBD><CFA2><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
2019-10-18 11:50:46 +08:00
void UpdateFromActor();
2019-12-31 16:01:41 +08:00
b2Body* GetB2Body() const;
void SetB2Body(b2Body* body);
2019-12-23 18:05:08 +08:00
private:
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-10-31 20:34:38 +08:00
void UpdateFixtureFilter(b2Fixture* fixture);
2019-12-31 16:01:41 +08:00
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Destroy();
2019-12-23 18:05:08 +08:00
private:
2019-10-18 11:50:46 +08:00
Actor* actor_;
2019-11-06 16:29:36 +08:00
World* world_;
2019-10-18 11:50:46 +08:00
b2Body* body_;
2019-10-31 20:34:38 +08:00
uint16_t category_bits_;
uint16_t mask_bits_;
int16_t group_index_;
2019-10-18 11:50:46 +08:00
};
2019-12-31 16:01:41 +08:00
/** @} */
inline Body::Body(World* world, ActorPtr actor) : Body(world, actor.get()) {}
inline FixtureList Body::GetFixtureList() const { KGE_ASSERT(body_); return FixtureList(Fixture(body_->GetFixtureList())); }
inline ContactEdgeList Body::GetContactList() const { KGE_ASSERT(body_); return ContactEdgeList(ContactEdge(body_->GetContactList())); }
inline uint16_t Body::GetCategoryBits() const { return category_bits_; }
inline uint16_t Body::GetMaskBits() const { return mask_bits_; }
inline int16_t Body::GetGroupIndex() const { return group_index_; }
inline float Body::GetBodyRotation() const { KGE_ASSERT(body_); return math::Radian2Degree(body_->GetAngle()); }
inline void Body::SetBodyRotation(float angle) { SetBodyTransform(GetBodyPosition(), angle); }
inline void Body::SetBodyPosition(Point const& pos) { SetBodyTransform(pos, GetBodyRotation()); }
inline float Body::GetMass() const { KGE_ASSERT(body_); return body_->GetMass(); }
inline float Body::GetInertia() const { KGE_ASSERT(body_); return body_->GetInertia(); }
inline Body::Type Body::GetType() const { KGE_ASSERT(body_); return Type(body_->GetType()); }
inline void Body::SetType(Type type) { KGE_ASSERT(body_); body_->SetType(static_cast<b2BodyType>(type)); }
inline float Body::GetGravityScale() const { KGE_ASSERT(body_); return body_->GetGravityScale(); }
inline void Body::SetGravityScale(float scale) { KGE_ASSERT(body_); body_->SetGravityScale(scale); }
inline bool Body::IsIgnoreRotation() const { KGE_ASSERT(body_); return body_->IsFixedRotation(); }
inline void Body::SetIgnoreRotation(bool flag) { KGE_ASSERT(body_); body_->SetFixedRotation(flag); }
inline bool Body::IsBullet() const { KGE_ASSERT(body_); return body_->IsBullet(); }
inline void Body::SetBullet(bool flag) { KGE_ASSERT(body_); body_->SetBullet(flag); }
inline bool Body::IsAwake() const { KGE_ASSERT(body_); return body_->IsAwake(); }
inline void Body::SetAwake(bool flag) { KGE_ASSERT(body_); body_->SetAwake(flag); }
inline bool Body::IsSleepingAllowed() const { KGE_ASSERT(body_); return body_->IsSleepingAllowed(); }
inline void Body::SetSleepingAllowed(bool flag) { KGE_ASSERT(body_); body_->SetSleepingAllowed(flag); }
inline bool Body::IsActive() const { KGE_ASSERT(body_); return body_->IsActive(); }
inline void Body::SetActive(bool flag) { KGE_ASSERT(body_); body_->SetActive(flag); }
inline Actor* Body::GetActor() const { return actor_; }
inline void Body::SetActor(Actor* actor) { actor_ = actor; }
inline b2Body* Body::GetB2Body() const { return body_; }
inline World* Body::GetWorld() const { return world_; }
2019-10-18 11:50:46 +08:00
}
}