Kiwano Engine
v1.3.x
Body.h
1
// Copyright (c) 2018-2019 Kiwano - Nomango
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to deal
5
// in the Software without restriction, including without limitation the rights
6
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
// copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in
11
// all copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
// THE SOFTWARE.
20
21
#pragma once
22
#include <kiwano-physics/Global.h>
23
24
#define KGE_COMP_PHYSIC_BODY "__KGE_PHYSIC_BODY__"
25
26
namespace
kiwano
27
{
28
namespace
physics
29
{
30
31
class
World;
32
40
class
KGE_API
Body
:
public
Component
41
{
42
friend
class
World
;
43
44
public
:
49
Body
(b2Body* body, b2World* world =
nullptr
);
50
51
virtual
~Body
();
52
55
b2Body* GetB2Body()
const
;
56
59
Point
GetLocalPoint(
const
Point
& world)
const
;
60
63
Vec2
GetLocalVector(
const
Vec2
& world)
const
;
64
67
Point
GetWorldPoint(
const
Point
& local)
const
;
68
71
Vec2
GetWorldVector(
const
Vec2
& local)
const
;
72
73
protected
:
76
void
InitComponent(
Actor
* actor)
override
;
77
80
void
DestroyComponent()
override
;
81
84
void
UpdateFromActor(
Actor
* actor);
85
88
void
UpdateFromActor(
Actor
* actor,
const
Matrix3x2
& actor_to_world,
float
parent_rotation);
89
92
void
BeforeSimulation(
Actor
* actor,
const
Matrix3x2
& parent_to_world,
const
Matrix3x2
& actor_to_world,
93
float
parent_rotation);
94
97
void
AfterSimulation(
Actor
* actorconst,
const
Matrix3x2
& parent_to_world,
float
parent_rotation);
98
99
private
:
100
b2World* b2world_;
101
b2Body* b2body_;
102
103
// Point offset_;
104
Point
position_cached_;
105
};
106
109
inline
b2Body*
Body::GetB2Body
()
const
110
{
111
return
b2body_;
112
}
113
114
}
// namespace physics
115
}
// namespace kiwano
kiwano::Actor
角色
Definition:
Actor.h:63
kiwano::Component
组件
Definition:
Component.h:48
kiwano::physics::Body
物体
Definition:
Body.h:41
kiwano::physics::Body::GetB2Body
b2Body * GetB2Body() const
获取b2Body
Definition:
Body.h:109
kiwano::physics::World
物理世界
Definition:
World.h:47
kiwano::math::Matrix3x2T< float >
kiwano::math::Vec2T< float >
src
kiwano-physics
Body.h
制作者
1.9.4