summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcommon/object.cpp79
-rwxr-xr-xcommon/object.h2
-rw-r--r--common/piece.cpp58
-rw-r--r--common/piece.h2
-rw-r--r--common/project.cpp83
-rw-r--r--common/project.h2
-rw-r--r--docs/CHANGES.txt3
7 files changed, 180 insertions, 49 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
diff --git a/common/object.h b/common/object.h
index 54be4d0..291a534 100755
--- a/common/object.h
+++ b/common/object.h
@@ -163,6 +163,8 @@ class Object
public:
void CalculateSingleKey (unsigned short nTime, bool bAnimation, int keytype, float *value) const;
void ChangeKey (unsigned short time, bool animation, bool addkey, const float *param, unsigned char keytype);
+ virtual void InsertTime (unsigned short start, bool animation, unsigned short time);
+ virtual void RemoveTime (unsigned short start, bool animation, unsigned short time);
int GetKeyTypeCount () const
{ return m_nKeyInfoCount; }
diff --git a/common/piece.cpp b/common/piece.cpp
index abbddf7..c65ded8 100644
--- a/common/piece.cpp
+++ b/common/piece.cpp
@@ -414,6 +414,64 @@ void Piece::Select (bool bSelecting, bool bFocus, bool bMultiple)
}
}
+void Piece::InsertTime (unsigned short start, bool animation, unsigned short time)
+{
+ if (animation)
+ {
+ if (m_nFrameShow >= start)
+ m_nFrameShow = min (m_nFrameShow + time, project->GetTotalFrames ());
+
+ if (m_nFrameHide >= start)
+ m_nFrameHide = min (m_nFrameHide + time, project->GetTotalFrames ());
+
+ if (m_nFrameShow > project->GetCurrentTime ())
+ Select (false, false, false);
+ }
+ else
+ {
+ if (m_nStepShow >= start)
+ m_nStepShow = min (m_nStepShow + time, 255);
+
+ if (m_nStepHide >= start)
+ m_nStepHide = min (m_nStepHide + time, 255);
+
+ if (m_nStepShow > project->GetCurrentTime ())
+ Select (false, false, false);
+ }
+
+ Object::InsertTime (start, animation, time);
+}
+
+void Piece::RemoveTime (unsigned short start, bool animation, unsigned short time)
+{
+ if (animation)
+ {
+ if (m_nFrameShow >= start)
+ m_nFrameShow = max (m_nFrameShow - time, 1);
+
+ if (m_nFrameHide == project->GetTotalFrames ())
+ m_nFrameHide = project->GetTotalFrames ();
+ else
+ m_nFrameHide = max (m_nFrameHide - time, 1);
+
+ if (m_nFrameHide < project->GetCurrentTime ())
+ Select (false, false, false);
+ }
+ else
+ {
+ if (m_nStepShow >= start)
+ m_nStepShow = max (m_nStepShow - time, 1);
+
+ if (m_nStepHide != 255)
+ m_nStepHide = max (m_nStepHide - time, 1);
+
+ if (m_nStepHide < project->GetCurrentTime ())
+ Select (false, false, false);
+ }
+
+ Object::RemoveTime (start, animation, time);
+}
+
void Piece::LineFacet(float* p1, float* p2, float* p3, float* p4, LC_CLICKLINE* pLine)
{
double t, t1, t2, x, y, z, plane[4];
diff --git a/common/piece.h b/common/piece.h
index 1cbf4f6..d6abfa0 100644
--- a/common/piece.h
+++ b/common/piece.h
@@ -32,6 +32,8 @@ public:
~Piece ();
void Select (bool bSelecting, bool bFocus, bool bMultiple);
+ virtual void InsertTime (unsigned short start, bool animation, unsigned short time);
+ virtual void RemoveTime (unsigned short start, bool animation, unsigned short time);
diff --git a/common/project.cpp b/common/project.cpp
index bc8baf9..cd4636d 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -5561,62 +5561,47 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
SystemUpdateTime(m_bAnimation, m_nCurStep, 255);
} break;
- case LC_VIEW_STEP_INSERT:
- {
- bool redraw = false;
-
- if (m_bAnimation)
- break;
-
- for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
- {
- unsigned char t = pPiece->GetStepShow();
-
- if (t >= m_nCurStep && t < 255)
- {
- redraw = true;
- pPiece->SetStepShow (t+1);
+ case LC_VIEW_STEP_INSERT:
+ {
+ for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
+ pPiece->InsertTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- if (pPiece->IsSelected () && t == m_nCurStep)
- pPiece->Select (false, false, false);
- }
- }
+ for (Camera* pCamera = m_pCameras; pCamera; pCamera = pCamera->m_pNext)
+ pCamera->InsertTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- if (redraw)
- {
- SetModifiedFlag (true);
- CheckPoint ("Adding Step");
- UpdateAllViews ();
- UpdateSelection ();
- }
- } break;
+ for (Light* pLight = m_pLights; pLight; pLight = pLight->m_pNext)
+ pLight->InsertTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- case LC_VIEW_STEP_DELETE:
- {
- bool redraw = false;
+ SetModifiedFlag (true);
+ if (m_bAnimation)
+ CheckPoint ("Adding Frame");
+ else
+ CheckPoint ("Adding Step");
+ CalculateStep ();
+ UpdateAllViews ();
+ UpdateSelection ();
+ } break;
- if (m_bAnimation)
- break;
+ case LC_VIEW_STEP_DELETE:
+ {
+ for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
+ pPiece->RemoveTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
- {
- unsigned char t = pPiece->GetStepShow();
+ for (Camera* pCamera = m_pCameras; pCamera; pCamera = pCamera->m_pNext)
+ pCamera->RemoveTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- if (t >= m_nCurStep && t > 1)
- {
- redraw = true;
- pPiece->SetStepShow (t-1);
- }
- }
+ for (Light* pLight = m_pLights; pLight; pLight = pLight->m_pNext)
+ pLight->RemoveTime (m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, 1);
- if (redraw)
- {
- SetModifiedFlag (true);
- CheckPoint ("Removing Step");
- UpdateAllViews ();
- UpdateSelection ();
- }
- } break;
+ SetModifiedFlag (true);
+ if (m_bAnimation)
+ CheckPoint ("Removing Frame");
+ else
+ CheckPoint ("Removing Step");
+ CalculateStep ();
+ UpdateAllViews ();
+ UpdateSelection ();
+ } break;
case LC_VIEW_STOP:
{
diff --git a/common/project.h b/common/project.h
index 9e91d53..882077c 100644
--- a/common/project.h
+++ b/common/project.h
@@ -73,6 +73,8 @@ public:
*from = m_bAnimation ? m_nCurFrame : m_nCurStep;
*to = m_bAnimation ? m_nTotalFrames : 255;
}
+ unsigned short GetTotalFrames () const
+ { return m_nTotalFrames; }
void GetArrays(Piece** ppPiece, Camera** ppCamera, Light** ppLight)
{
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index 2fd92df..cc0c2dd 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -1,5 +1,8 @@
This is a changelog for developers only, not for ordinary users.
+23/03/2001
+ - Update object keys when adding/removing steps.
+
21/03/2001
- Improved Linux About dialog.