summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/wobbly.c
diff options
context:
space:
mode:
authorkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-30 13:13:33 +0000
committerkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-30 13:13:33 +0000
commit50acc7d4a3703b0309690c387a71b18888f5be76 (patch)
tree970467c71f91feaa6f89c291535f7a3f760b6f3e /beryl-plugins/src/wobbly.c
parent4e3ed792f4e36ec1bbee616bb593bf573a53d9e2 (diff)
downloadmarex-dev-50acc7d4a3703b0309690c387a71b18888f5be76.tar.gz
marex-dev-50acc7d4a3703b0309690c387a71b18888f5be76.tar.bz2
Reduce code duplication
git-svn-id: file:///beryl/trunk@1465 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/wobbly.c')
-rw-r--r--beryl-plugins/src/wobbly.c119
1 files changed, 30 insertions, 89 deletions
diff --git a/beryl-plugins/src/wobbly.c b/beryl-plugins/src/wobbly.c
index f3b4b4e..797dc17 100644
--- a/beryl-plugins/src/wobbly.c
+++ b/beryl-plugins/src/wobbly.c
@@ -1906,91 +1906,32 @@ springExertForces (Spring * spring, float k)
}
static Bool
-objectReleaseWestEdge (CompWindow * w, Model * model, Object * object)
-{
- if (fabs (object->velocity.x) > object->vertEdge.velocity)
- {
- object->position.x += object->velocity.x * 2.0f;
-
- model->snapCnt[WEST]--;
-
- object->vertEdge.snapped = FALSE;
- object->edgeMask = 0;
-
- modelUpdateSnapping (w, model);
-
- return TRUE;
- }
-
- object->velocity.x = 0.0f;
-
- return FALSE;
-}
-
-static Bool
-objectReleaseEastEdge (CompWindow * w, Model * model, Object * object)
-{
- if (fabs (object->velocity.x) > object->vertEdge.velocity)
- {
- object->position.x += object->velocity.x * 2.0f;
-
- model->snapCnt[EAST]--;
-
- object->vertEdge.snapped = FALSE;
- object->edgeMask = 0;
-
- modelUpdateSnapping (w, model);
-
- return TRUE;
- }
-
- object->velocity.x = 0.0f;
-
- return FALSE;
-}
-
-static Bool
-objectReleaseNorthEdge (CompWindow * w, Model * model, Object * object)
-{
- if (fabs (object->velocity.y) > object->horzEdge.velocity)
- {
- object->position.y += object->velocity.y * 2.0f;
-
- model->snapCnt[NORTH]--;
-
- object->horzEdge.snapped = FALSE;
- object->edgeMask = 0;
-
- modelUpdateSnapping (w, model);
-
- return TRUE;
- }
-
- object->velocity.y = 0.0f;
-
- return FALSE;
-}
-
-static Bool
-objectReleaseSouthEdge (CompWindow * w, Model * model, Object * object)
-{
- if (fabs (object->velocity.y) > object->horzEdge.velocity)
- {
- object->position.y += object->velocity.y * 2.0f;
-
- model->snapCnt[SOUTH]--;
-
- object->horzEdge.snapped = FALSE;
- object->edgeMask = 0;
-
- modelUpdateSnapping (w, model);
-
- return TRUE;
- }
-
- object->velocity.y = 0.0f;
-
- return FALSE;
+objectReleaseEdge (CompWindow * w, Model * model, Object * object, short int edge)
+{
+ if (((NORTH == edge || edge == SOUTH) && (fabs (object->velocity.y) > object->horzEdge.velocity))
+ || ((WEST == edge || edge == EAST) && (fabs (object->velocity.x) > object->vertEdge.velocity)))
+ {
+
+ model->snapCnt[edge]--;
+
+ if(edge == WEST || edge == EAST) {
+ object->position.x += object->velocity.x * 2.0f;
+ object->vertEdge.snapped = FALSE;
+ } else {
+ object->position.y += object->velocity.y * 2.0f;
+ object->horzEdge.snapped = FALSE;
+ }
+ object->edgeMask = 0;
+ modelUpdateSnapping (w, model);
+ return TRUE;
+ }
+
+ if(edge == WEST || edge == EAST)
+ object->velocity.x = 0.0f;
+ else
+ object->velocity.y = 0.0f;
+
+ return FALSE;
}
static float
@@ -2028,7 +1969,7 @@ modelStepObject (CompWindow * window,
findNextWestEdge (window, object);
if (object->vertEdge.snapped == FALSE ||
- objectReleaseWestEdge (window, model, object))
+ objectReleaseEdge (window, model, object,WEST))
{
object->position.x += object->velocity.x;
@@ -2063,7 +2004,7 @@ modelStepObject (CompWindow * window,
findNextEastEdge (window, object);
if (object->vertEdge.snapped == FALSE ||
- objectReleaseEastEdge (window, model, object))
+ objectReleaseEdge (window, model, object,EAST))
{
object->position.x += object->velocity.x;
@@ -2101,7 +2042,7 @@ modelStepObject (CompWindow * window,
findNextNorthEdge (window, object);
if (object->horzEdge.snapped == FALSE ||
- objectReleaseNorthEdge (window, model, object))
+ objectReleaseEdge (window, model, object,NORTH))
{
object->position.y += object->velocity.y;
@@ -2136,7 +2077,7 @@ modelStepObject (CompWindow * window,
findNextSouthEdge (window, object);
if (object->horzEdge.snapped == FALSE ||
- objectReleaseSouthEdge (window, model, object))
+ objectReleaseEdge (window, model, object,SOUTH))
{
object->position.y += object->velocity.y;