[vlmc-devel] Track.qml: Simplify the collision detection
Yikai Lu
git at videolan.org
Mon Aug 1 11:40:44 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun Jul 31 15:36:51 2016 +0900| [5e50c347b9fd424ea87a4c8bd469c1798391f332] | committer: Yikai Lu
Track.qml: Simplify the collision detection
> https://code.videolan.org/videolan/vlmc/commit/5e50c347b9fd424ea87a4c8bd469c1798391f332
---
src/Gui/timeline/Track.qml | 42 ++++++++++++++----------------------------
1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 86f94a7..3a17bc8 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -90,34 +90,20 @@ Item {
// Set a right position
//
// HACK: If magnetic mode, consider clips bigger.
- if ( useMagneticMode === true ) {
- if ( cx + cw > newX && newX + sw > cx )
- isCollided = true;
-
- cw += magneticMargin * 2
- cx -= magneticMargin
- if ( cx + cw > newX && newX + sw > cx ) {
- if ( cx > newX ) {
- if ( cx - sw > 0 )
- newX = cx - sw + magneticMargin;
- else
- newX = oldX;
- } else {
- newX = cx + cw - magneticMargin;
- }
- }
- }
- else {
- if ( cx + cw > newX && newX + sw > cx ) {
- isCollided = true;
- if ( cx > newX ) {
- if ( cx - sw > 0 )
- newX = cx - sw;
- else
- newX = oldX;
- } else {
- newX = cx + cw;
- }
+ var clipMargin = useMagneticMode ? magneticMargin : 0;
+ if ( cx + cw > newX && newX + sw > cx )
+ isCollided = true;
+
+ cw += clipMargin * 2
+ cx -= clipMargin
+ if ( cx + cw > newX && newX + sw > cx ) {
+ if ( cx > newX ) {
+ if ( cx - sw > 0 )
+ newX = cx - sw + clipMargin;
+ else
+ newX = oldX;
+ } else {
+ newX = cx + cw - clipMargin;
}
}
if ( isCollided )
More information about the Vlmc-devel
mailing list