Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
0f195135
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f195135
编写于
10月 08, 2015
作者:
V
Viktor Lidholt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adds support for keeping track of contact points in physics
上级
78dfdde4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
76 addition
and
6 deletion
+76
-6
skysprites/lib/physics_node.dart
skysprites/lib/physics_node.dart
+76
-6
未找到文件。
skysprites/lib/physics_node.dart
浏览文件 @
0f195135
...
...
@@ -183,7 +183,57 @@ class PhysicsNode extends Node {
}
}
}
canvas
.
restore
();
// Draw contacts
for
(
box2d
.
ContactEdge
edge
=
body
.
getContactList
();
edge
!=
null
;
edge
=
edge
.
next
)
{
box2d
.
Contact
contact
=
edge
.
contact
;
Vector2
cA
=
new
Vector2
.
zero
();
Vector2
cB
=
new
Vector2
.
zero
();
box2d
.
Fixture
fixtureA
=
contact
.
fixtureA
;
box2d
.
Fixture
fixtureB
=
contact
.
fixtureB
;
fixtureA
.
getAABB
(
contact
.
getChildIndexA
()).
getCenterToOut
(
cA
);
fixtureB
.
getAABB
(
contact
.
getChildIndexB
()).
getCenterToOut
(
cB
);
Point
p1
=
new
Point
(
cA
.
x
*
b2WorldToNodeConversionFactor
,
cA
.
y
*
b2WorldToNodeConversionFactor
);
Point
p2
=
new
Point
(
cB
.
x
*
b2WorldToNodeConversionFactor
,
cB
.
y
*
b2WorldToNodeConversionFactor
);
shapePaint
.
color
=
new
Color
(
0x33ffffff
);
canvas
.
drawLine
(
p1
,
p2
,
shapePaint
);
box2d
.
WorldManifold
worldManifold
=
new
box2d
.
WorldManifold
();
contact
.
getWorldManifold
(
worldManifold
);
shapePaint
.
color
=
new
Color
(
0xffffffff
);
for
(
Vector2
pt
in
worldManifold
.
points
)
{
Point
pCenter
=
new
Point
(
pt
.
x
*
b2WorldToNodeConversionFactor
,
pt
.
y
*
b2WorldToNodeConversionFactor
);
Offset
offset
=
new
Offset
(
worldManifold
.
normal
.
x
*
5.0
,
worldManifold
.
normal
.
y
*
5.0
);
Point
p2
=
pCenter
+
offset
;
Point
p1
=
new
Point
(
pCenter
.
x
-
offset
.
dx
,
pCenter
.
y
-
offset
.
dy
);
canvas
.
drawLine
(
p1
,
p2
,
shapePaint
);
canvas
.
drawCircle
(
pCenter
,
5.0
,
shapePaint
);
}
}
}
}
}
...
...
@@ -195,7 +245,9 @@ class PhysicsContact {
this
.
shapeA
,
this
.
shapeB
,
this
.
isTouching
,
this
.
isEnabled
this
.
isEnabled
,
this
.
touchingPoints
,
this
.
touchingNormal
);
final
Node
nodeA
;
...
...
@@ -204,6 +256,8 @@ class PhysicsContact {
final
PhysicsShape
shapeB
;
final
isTouching
;
bool
isEnabled
;
final
List
<
Point
>
touchingPoints
;
final
Offset
touchingNormal
;
}
class
_ContactCallbackInfo
{
...
...
@@ -264,19 +318,35 @@ class _ContactHandler extends box2d.ContactListener {
if
(
match
)
{
// We have contact and a matched callback, setup contact info
List
<
Point
>
touchingPoints
=
null
;
Offset
touchingNormal
=
null
;
// Fetch touching points, if any
if
(
b2Contact
.
isTouching
())
{
box2d
.
WorldManifold
manifold
=
new
box2d
.
WorldManifold
();
b2Contact
.
getWorldManifold
(
manifold
);
touchingNormal
=
new
Offset
(
manifold
.
normal
.
x
,
manifold
.
normal
.
y
);
touchingPoints
=
[];
for
(
Vector2
vec
in
manifold
.
points
)
{
touchingPoints
.
add
(
new
Point
(
vec
.
x
*
physicsNode
.
b2WorldToNodeConversionFactor
,
vec
.
y
*
physicsNode
.
b2WorldToNodeConversionFactor
));
}
}
// Create the contact
PhysicsContact
contact
=
new
PhysicsContact
(
bodyA
.
_node
,
bodyB
.
_node
,
fixtureA
.
userData
,
fixtureB
.
userData
,
b2Contact
.
isTouching
(),
b2Contact
.
isEnabled
()
b2Contact
.
isEnabled
(),
touchingPoints
,
touchingNormal
);
if
(
type
==
PhysicsContactType
.
postSolve
)
{
}
// Make callback
info
.
callback
(
type
,
contact
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录