2019-10-18 11:50:46 +08:00
|
|
|
|
// Copyright (c) 2018-2019 Kiwano - Nomango
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-10-18 11:50:46 +08:00
|
|
|
|
// 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:
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-10-18 11:50:46 +08:00
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
// all copies or substantial portions of the Software.
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-10-18 11:50:46 +08:00
|
|
|
|
// 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
|
2020-01-21 10:09:55 +08:00
|
|
|
|
#include <kiwano-physics/Fixture.h>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
#include <kiwano-physics/ContactEdge.h>
|
2019-10-18 11:50:46 +08:00
|
|
|
|
|
|
|
|
|
|
namespace kiwano
|
|
|
|
|
|
{
|
2020-01-21 10:09:55 +08:00
|
|
|
|
namespace physics
|
|
|
|
|
|
{
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-22 17:24:31 +08:00
|
|
|
|
class PhysicWorld;
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* \addtogroup Physics
|
|
|
|
|
|
* @{
|
|
|
|
|
|
*/
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
class KGE_API PhysicBody : public Component
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
2020-02-22 17:24:31 +08:00
|
|
|
|
friend class PhysicWorld;
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
public:
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
enum class Type
|
|
|
|
|
|
{
|
2020-03-19 14:28:50 +08:00
|
|
|
|
Static = 0, ///< <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
|
|
|
|
|
Kinematic, ///< <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>
|
|
|
|
|
|
Dynamic, ///< <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-02-06 16:54:47 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param world <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param type <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-07-22 21:08:48 +08:00
|
|
|
|
PhysicBody(PhysicWorld* world, Type type);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
virtual ~PhysicBody();
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] world <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
bool Init(PhysicWorld* world);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>Ӽо<D3BC>
|
2020-02-06 16:54:47 +08:00
|
|
|
|
void AddFixture(FixturePtr fixture);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>μо<CEBC>
|
|
|
|
|
|
/// @param radius Բ<>ΰ뾶
|
|
|
|
|
|
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
/// @param
|
|
|
|
|
|
Fixture* AddCircleShape(float radius, float density, float friction = 0.2f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>Ӿ<EFBFBD><D3BE>μо<CEBC>
|
|
|
|
|
|
/// @param size <20><><EFBFBD>δ<EFBFBD>С
|
|
|
|
|
|
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
Fixture* AddRectShape(const Vec2& size, float density, float friction = 0.2f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>μо<CEBC>
|
|
|
|
|
|
/// @param vertexs <20><><EFBFBD><EFBFBD><EFBFBD>ζ˵<CEB6>
|
|
|
|
|
|
/// @param density <20><><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
Fixture* AddPolygonShape(const Vector<Point>& vertexs, float density, float friction = 0.2f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
Fixture* AddEdgeShape(const Point& p1, const Point& p2, float density, float friction = 0.2f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
Fixture* AddChainShape(const Vector<Point>& vertices, bool loop, float density, float friction = 0.2f);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƴ<EFBFBD><C6B3>о<EFBFBD>
|
2020-02-06 16:54:47 +08:00
|
|
|
|
void RemoveFixture(FixturePtr fixture);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD>мо<D0BC>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void RemoveAllFixtures();
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD>о<EFBFBD><D0BE>б<EFBFBD>
|
2020-02-06 16:54:47 +08:00
|
|
|
|
FixtureList GetFixtureList() const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD>б<EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
ContactEdgeList GetContactList() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
uint16_t GetCategoryBits() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetCategoryBits(uint16_t category_bits);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
uint16_t GetMaskBits() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetMaskBits(uint16_t mask_bits);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
int16_t GetGroupIndex() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetGroupIndex(int16_t index);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>ת<EFBFBD>Ƕ<EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
float GetRotation() const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void SetRotation(float angle);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
Point GetPosition() const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
void SetPosition(const Point& pos);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief λ<>ú<EFBFBD><C3BA><EFBFBD>ת<EFBFBD>任
|
2020-02-19 12:09:50 +08:00
|
|
|
|
void SetTransform(const Point& pos, float angle);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> [kg]
|
2020-01-21 10:09:55 +08:00
|
|
|
|
float GetMass() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
float GetInertia() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void GetMassData(float* mass, Point* center, float* inertia) const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
void SetMassData(float mass, const Point& center, float inertia);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void ResetMassData();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>λ<EFBFBD><CEBB>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
Point GetLocalPoint(const Point& world) const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-23 14:56:14 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
Vec2 GetLocalVector(const Vec2& world) const;
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>λ<EFBFBD><CEBB>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
Point GetWorldPoint(const Point& local) const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-23 14:56:14 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
Vec2 GetWorldVector(const Vec2& local) const;
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
Point GetLocalCenter() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
Point GetWorldCenter() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
Type GetType() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetType(Type type);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
float GetGravityScale() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetGravityScale(float scale);
|
|
|
|
|
|
|
2020-02-23 14:56:14 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
float GetLinearDamping() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
void SetLinearDamping(float damping);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
float GetAngularDamping() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
2020-02-23 14:56:14 +08:00
|
|
|
|
void SetAngularDamping(float damping);
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
void ApplyForce(const Vec2& force, const Point& point, bool wake = true);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @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>
|
2020-02-19 12:09:50 +08:00
|
|
|
|
void ApplyForceToCenter(const Vec2& force, bool wake = true);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief ʩ<><CAA9>Ť<EFBFBD><C5A4>
|
|
|
|
|
|
/// @param torque Ť<><C5A4>
|
|
|
|
|
|
/// @param wake <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void ApplyTorque(float torque, bool wake = false);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ת<EFBFBD>Ƕ<EFBFBD><C7B6>Ƿ<EFBFBD><C7B7>̶<EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
bool IsIgnoreRotation() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>̶<EFBFBD><CCB6><EFBFBD>ת<EFBFBD>Ƕ<EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetIgnoreRotation(bool flag);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
bool IsBullet() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetBullet(bool flag);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD>״̬
|
2020-01-21 10:09:55 +08:00
|
|
|
|
bool IsAwake() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>״̬
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetAwake(bool flag);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
bool IsSleepingAllowed() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetSleepingAllowed(bool flag);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
bool IsActive() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
2020-01-21 10:09:55 +08:00
|
|
|
|
void SetActive(bool flag);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
PhysicWorld* GetWorld() const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ȡb2Body
|
2020-01-21 10:09:55 +08:00
|
|
|
|
b2Body* GetB2Body() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>b2Body
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void SetB2Body(b2Body* body);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
protected:
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void InitComponent(Actor* actor) override;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void DestroyComponent() override;
|
|
|
|
|
|
|
2020-02-22 17:24:31 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
2020-02-22 17:24:31 +08:00
|
|
|
|
void UpdateFromActor(Actor* actor);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
2020-02-22 17:24:31 +08:00
|
|
|
|
void UpdateFromActor(Actor* actor, const Matrix3x2& actor_to_world, float parent_rotation);
|
|
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>¼о߹<D0BE><DFB9><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-19 11:50:05 +08:00
|
|
|
|
void UpdateFixtureFilter(b2Fixture* fixture);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-22 17:24:31 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ
|
2020-02-22 17:24:31 +08:00
|
|
|
|
void BeforeSimulation(Actor* actor, const Matrix3x2& parent_to_world, const Matrix3x2& actor_to_world,
|
|
|
|
|
|
float parent_rotation);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-22 17:24:31 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-02-22 17:24:31 +08:00
|
|
|
|
void AfterSimulation(Actor* actorconst, const Matrix3x2& parent_to_world, float parent_rotation);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
PhysicWorld* world_;
|
|
|
|
|
|
b2Body* body_;
|
|
|
|
|
|
uint16_t category_bits_;
|
|
|
|
|
|
uint16_t mask_bits_;
|
|
|
|
|
|
int16_t group_index_;
|
2020-02-06 16:54:47 +08:00
|
|
|
|
|
2020-02-22 17:24:31 +08:00
|
|
|
|
PhysicBody::Type type_;
|
2020-02-06 16:54:47 +08:00
|
|
|
|
Vector<FixturePtr> fixtures_;
|
2020-02-22 17:24:31 +08:00
|
|
|
|
|
|
|
|
|
|
Point offset_;
|
|
|
|
|
|
Point position_cached_;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline FixtureList PhysicBody::GetFixtureList() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
2020-02-06 16:54:47 +08:00
|
|
|
|
|
|
|
|
|
|
if (!body_->GetFixtureList())
|
|
|
|
|
|
return FixtureList();
|
|
|
|
|
|
|
|
|
|
|
|
Fixture* fixture = static_cast<Fixture*>(body_->GetFixtureList()->GetUserData());
|
|
|
|
|
|
return FixtureList(fixture);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline ContactEdgeList PhysicBody::GetContactList() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
2020-02-19 11:50:05 +08:00
|
|
|
|
ContactEdge edge;
|
|
|
|
|
|
edge.SetB2ContactEdge(body_->GetContactList());
|
|
|
|
|
|
return ContactEdgeList(edge);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline uint16_t PhysicBody::GetCategoryBits() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
return category_bits_;
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline uint16_t PhysicBody::GetMaskBits() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
return mask_bits_;
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline int16_t PhysicBody::GetGroupIndex() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
return group_index_;
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline float PhysicBody::GetRotation() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return math::Radian2Degree(body_->GetAngle());
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetRotation(float angle)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
2020-02-19 11:50:05 +08:00
|
|
|
|
SetTransform(GetPosition(), angle);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 12:09:50 +08:00
|
|
|
|
inline void PhysicBody::SetPosition(const Point& pos)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
2020-02-19 11:50:05 +08:00
|
|
|
|
SetTransform(pos, GetRotation());
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline float PhysicBody::GetMass() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->GetMass();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline float PhysicBody::GetInertia() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->GetInertia();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline PhysicBody::Type PhysicBody::GetType() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
2020-02-19 11:50:05 +08:00
|
|
|
|
return type_;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetType(Type type)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
2020-02-19 11:50:05 +08:00
|
|
|
|
if (type_ != type)
|
|
|
|
|
|
{
|
|
|
|
|
|
type_ = type;
|
|
|
|
|
|
if (body_)
|
|
|
|
|
|
{
|
|
|
|
|
|
body_->SetType(b2BodyType(type));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-01-21 10:09:55 +08:00
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline float PhysicBody::GetGravityScale() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->GetGravityScale();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetGravityScale(float scale)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetGravityScale(scale);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-23 14:56:14 +08:00
|
|
|
|
inline float PhysicBody::GetLinearDamping() const
|
|
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->GetLinearDamping();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void PhysicBody::SetLinearDamping(float damping)
|
|
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetLinearDamping(damping);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline float PhysicBody::GetAngularDamping() const
|
|
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->GetAngularDamping();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void PhysicBody::SetAngularDamping(float damping)
|
|
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetAngularDamping(damping);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline bool PhysicBody::IsIgnoreRotation() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->IsFixedRotation();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetIgnoreRotation(bool flag)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetFixedRotation(flag);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline bool PhysicBody::IsBullet() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->IsBullet();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetBullet(bool flag)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetBullet(flag);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline bool PhysicBody::IsAwake() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->IsAwake();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetAwake(bool flag)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetAwake(flag);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline bool PhysicBody::IsSleepingAllowed() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->IsSleepingAllowed();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetSleepingAllowed(bool flag)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetSleepingAllowed(flag);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline bool PhysicBody::IsActive() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
return body_->IsActive();
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline void PhysicBody::SetActive(bool flag)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
KGE_ASSERT(body_);
|
|
|
|
|
|
body_->SetActive(flag);
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline b2Body* PhysicBody::GetB2Body() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
return body_;
|
|
|
|
|
|
}
|
2019-12-31 16:01:41 +08:00
|
|
|
|
|
2020-02-19 11:50:05 +08:00
|
|
|
|
inline PhysicWorld* PhysicBody::GetWorld() const
|
2020-01-21 10:09:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
return world_;
|
2019-10-18 11:50:46 +08:00
|
|
|
|
}
|
2020-02-19 11:50:05 +08:00
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
} // namespace physics
|
|
|
|
|
|
} // namespace kiwano
|