Fixed reset cameras option.

This commit is contained in:
leo 2015-01-16 02:07:31 +00:00
parent af37e7008d
commit 88e935ccd8
6 changed files with 27 additions and 86 deletions

View file

@ -73,7 +73,6 @@ void lcCamera::Initialize()
m_zFar = 12500.0f;
mState = 0;
m_nType = LC_CAMERA_USER;
m_pTR = NULL;
memset(m_strName, 0, sizeof(m_strName));
@ -360,7 +359,7 @@ bool lcCamera::FileLoad(lcFile& file)
ch = file.ReadU8();
if (ch & 1)
mState |= LC_CAMERA_HIDDEN;
m_nType = file.ReadU8();
file.ReadU8();
}
}
@ -391,60 +390,6 @@ bool lcCamera::FileLoad(lcFile& file)
return true;
}
void lcCamera::FileSave(lcFile& file) const
{
file.WriteU8(LC_CAMERA_SAVE_VERSION);
file.WriteU8(1);
file.WriteU32(mPositionKeys.GetSize() + mTargetPositionKeys.GetSize() + mUpVectorKeys.GetSize());
for (int KeyIdx = 0; KeyIdx < mPositionKeys.GetSize(); KeyIdx++)
{
lcObjectKey<lcVector3>& Key = mPositionKeys[KeyIdx];
lcuint16 Step = lcMin(Key.Step, 0xFFFFU);
file.WriteU16(Step);
file.WriteFloats(Key.Value, 3);
file.WriteFloat(0);
file.WriteU8(0);
}
for (int KeyIdx = 0; KeyIdx < mTargetPositionKeys.GetSize(); KeyIdx++)
{
lcObjectKey<lcVector3>& Key = mTargetPositionKeys[KeyIdx];
lcuint16 Step = lcMin(Key.Step, 0xFFFFU);
file.WriteU16(Step);
file.WriteFloats(Key.Value, 3);
file.WriteFloat(0);
file.WriteU8(1);
}
for (int KeyIdx = 0; KeyIdx < mUpVectorKeys.GetSize(); KeyIdx++)
{
lcObjectKey<lcVector3>& Key = mUpVectorKeys[KeyIdx];
lcuint16 Step = lcMin(Key.Step, 0xFFFFU);
file.WriteU16(Step);
file.WriteFloats(Key.Value, 3);
file.WriteFloat(0);
file.WriteU8(2);
}
file.WriteU32(0);
lcuint8 ch = (lcuint8)strlen(m_strName);
file.WriteU8(ch);
file.WriteBuffer(m_strName, ch);
file.WriteFloat(m_fovy);
file.WriteFloat(m_zFar);
file.WriteFloat(m_zNear);
// version 5
file.WriteU8(mState & LC_CAMERA_HIDDEN ? 1 : 0);
file.WriteU8(m_nType);
}
void lcCamera::CompareBoundingBox(float box[6])
{
const lcVector3 Points[2] =

View file

@ -39,14 +39,6 @@ enum lcCameraSection
LC_CAMERA_SECTION_UPVECTOR
};
typedef enum
{
LC_CAMERA_FRONT,LC_CAMERA_BACK,
LC_CAMERA_TOP, LC_CAMERA_UNDER,
LC_CAMERA_LEFT, LC_CAMERA_RIGHT,
LC_CAMERA_MAIN, LC_CAMERA_USER
} LC_CAMERA_TYPES;
class lcCamera : public lcObject
{
public:
@ -223,14 +215,7 @@ public:
void SaveLDraw(QTextStream& Stream) const;
bool ParseLDrawLine(QTextStream& Stream);
public:
// void Hide()
// { mState = LC_CAMERA_HIDDEN; }
// void UnHide()
// { mState &= ~LC_CAMERA_HIDDEN; }
bool IsSide()
{ return m_nType < LC_CAMERA_MAIN; }
bool IsVisible() const
{ return (mState & LC_CAMERA_HIDDEN) == 0; }
@ -271,7 +256,6 @@ public:
void RemoveTime(lcStep Start, lcStep Time);
bool FileLoad(lcFile& file);
void FileSave(lcFile& file) const;
void Select(bool bSelecting, bool bFocus, bool bMultiple);
void CompareBoundingBox(float box[6]);
@ -314,7 +298,6 @@ protected:
void Initialize();
lcuint32 mState;
unsigned char m_nType;
};
#endif // _CAMERA_H_

View file

@ -43,6 +43,14 @@ lcMainWindow::~lcMainWindow()
gMainWindow = NULL;
}
void lcMainWindow::ResetCameras()
{
for (int ViewIdx = 0; ViewIdx < mViews.GetSize(); ViewIdx++)
mViews[ViewIdx]->SetDefaultCamera();
lcGetActiveModel()->DeleteAllCameras();
}
void lcMainWindow::AddView(View* View)
{
mViews.Add(View);
@ -672,21 +680,11 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
case LC_VIEW_CAMERA16:
mActiveView->SetCameraIndex(CommandId - LC_VIEW_CAMERA1);
break;
/*
case LC_VIEW_CAMERA_RESET:
{
for (int ViewIdx = 0; ViewIdx < mViews.GetSize(); ViewIdx++)
mViews[ViewIdx]->SetDefaultCamera();
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
delete mCameras[CameraIdx];
mCameras.RemoveAll();
case LC_VIEW_CAMERA_RESET:
ResetCameras();
break;
UpdateCameraMenu();
UpdateFocusObject(GetFocusObject());
UpdateAllViews();
} break;
*/
case LC_MODEL_NEW:
lcGetActiveProject()->CreateNewModel();
break;

View file

@ -112,6 +112,7 @@ public:
return mViews;
}
void ResetCameras();
void AddView(View* View);
void RemoveView(View* View);
void SetActiveView(View* ActiveView);

View file

@ -1784,6 +1784,19 @@ void lcModel::AddPiece()
SaveCheckpoint("Adding Piece");
}
void lcModel::DeleteAllCameras()
{
if (mCameras.IsEmpty())
return;
mCameras.DeleteAll();
gMainWindow->UpdateCameraMenu();
gMainWindow->UpdateFocusObject(GetFocusObject());
gMainWindow->UpdateAllViews();
SaveCheckpoint("Reseting Cameras");
}
void lcModel::DeleteSelectedObjects()
{
if (RemoveSelectedObjects())

View file

@ -186,6 +186,7 @@ public:
void RemoveStep();
void AddPiece();
void DeleteAllCameras();
void DeleteSelectedObjects();
void ShowSelectedPiecesEarlier();
void ShowSelectedPiecesLater();