Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ac2a8a66
Commit
ac2a8a66
authored
Oct 26, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sprite nodes now caches inverse transforms
parent
5d0c090d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
node.dart
packages/flutter_sprites/lib/src/node.dart
+11
-3
No files found.
packages/flutter_sprites/lib/src/node.dart
View file @
ac2a8a66
...
...
@@ -24,6 +24,7 @@ class Node {
double
_rotation
=
0.0
;
Matrix4
_transformMatrix
=
new
Matrix4
.
identity
();
Matrix4
_transformMatrixInverse
;
Matrix4
_transformMatrixNodeToBox
;
Matrix4
_transformMatrixBoxToNode
;
...
...
@@ -246,9 +247,7 @@ class Node {
return
position
;
}
else
if
(
physicsParent
is
PhysicsGroup
)
{
// Transform the position
Matrix4
inverseTransform
=
new
Matrix4
.
copy
(
physicsParent
.
transformMatrix
);
inverseTransform
.
invert
();
Vector4
parentPos
=
inverseTransform
.
transform
(
new
Vector4
(
position
.
x
,
position
.
y
,
0.0
,
1.0
));
Vector4
parentPos
=
physicsParent
.
_inverseMatrix
().
transform
(
new
Vector4
(
position
.
x
,
position
.
y
,
0.0
,
1.0
));
Point
newPos
=
new
Point
(
parentPos
.
x
,
parentPos
.
y
);
return
_positionToPhysics
(
newPos
,
physicsParent
.
parent
);
}
else
{
...
...
@@ -531,6 +530,7 @@ class Node {
/// changes that affects the matrix.
void
invalidateTransformMatrix
()
{
_transformMatrix
=
null
;
_transformMatrixInverse
=
null
;
_invalidateToBoxTransformMatrix
();
}
...
...
@@ -575,6 +575,14 @@ class Node {
return
_transformMatrixBoxToNode
;
}
Matrix4
_inverseMatrix
()
{
if
(
_transformMatrixInverse
==
null
)
{
_transformMatrixInverse
=
new
Matrix4
.
copy
(
transformMatrix
);
_transformMatrixInverse
.
invert
();
}
return
_transformMatrixInverse
;
}
/// Converts a point from the coordinate system of the [SpriteBox] to the local coordinate system of the node.
///
/// This method is particularly useful when handling pointer events and need the pointers position in a local
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment