summaryrefslogtreecommitdiff
path: root/common/object.cpp
diff options
context:
space:
mode:
authorleo2001-03-23 18:22:30 +0000
committerleo2001-03-23 18:22:30 +0000
commit86a640b8111add87c17d95844896c4f34b7920da (patch)
treece3b4d2f1fdf8ab97411d633d0c1c8ce95c912ab /common/object.cpp
parent09abe87225c12734aeda42225e4f4ebcce7c7584 (diff)
Update object keys when adding or removing steps.
git-svn-id: http://svn.leocad.org/trunk@258 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/object.cpp')
-rwxr-xr-xcommon/object.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/common/object.cpp b/common/object.cpp
index e4bf612..d229388 100755
--- a/common/object.cpp
+++ b/common/object.cpp
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <float.h>
#include <math.h>
+#include "globals.h"
+#include "project.h"
#include "object.h"
#include "matrix.h"
#include "vector.h"
@@ -329,6 +331,83 @@ void Object::CalculateSingleKey (unsigned short nTime, bool bAnimation, int keyt
value[j] = prev->param[j];
}
+void Object::InsertTime (unsigned short start, bool animation, unsigned short time)
+{
+ LC_OBJECT_KEY *node, *prev = NULL;
+ unsigned short last;
+ bool end[32];
+ int i;
+
+ for (i = 0; i < m_nKeyInfoCount; i++)
+ end[i] = false;
+
+ if (animation)
+ {
+ node = m_pAnimationKeys;
+ last = project->GetTotalFrames ();
+ }
+ else
+ {
+ node = m_pInstructionKeys;
+ last = 255;
+ }
+
+ for (; node != NULL; prev = node, node = node->next)
+ {
+ // skip everything before the start time
+ if ((node->time < start) || (node->time == 1))
+ continue;
+
+ // there's already a key at the end, delete this one
+ if (end[node->type])
+ {
+ prev->next = node->next;
+ free (node);
+ node = prev;
+
+ continue;
+ }
+
+ node->time += time;
+ if (node->time >= last)
+ {
+ node->time = last;
+ end[node->type] = true;
+ }
+ }
+}
+
+void Object::RemoveTime (unsigned short start, bool animation, unsigned short time)
+{
+ LC_OBJECT_KEY *node, *prev = NULL;
+
+ if (animation)
+ node = m_pAnimationKeys;
+ else
+ node = m_pInstructionKeys;
+
+ for (; node != NULL; prev = node, node = node->next)
+ {
+ // skip everything before the start time
+ if ((node->time < start) || (node->time == 1))
+ continue;
+
+ if (node->time < (start + time))
+ {
+ // delete this key
+ prev->next = node->next;
+ free (node);
+ node = prev;
+
+ continue;
+ }
+
+ node->time -= time;
+ if (node->time < 1)
+ node->time = 1;
+ }
+}
+
// =============================================================================
// BoundingBox stuff