Skip to content

Commit

Permalink
Fix setting float properties without a focus object.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Oct 3, 2024
1 parent 6603de2 commit 0ded25b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 100 deletions.
12 changes: 0 additions & 12 deletions common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ void lcModelProperties::ParseLDrawLine(QTextStream& Stream)
}
}

lcPOVRayOptions::lcPOVRayOptions() :
UseLGEO(false),
ExcludeFloor(false),
ExcludeBackground(false),
NoReflection(false),
NoShadow(false),
FloorAxis(1),
FloorAmbient(0.4f),
FloorDiffuse(0.4f),
FloorColor(0.8f,0.8f,0.8f)
{}

void lcPOVRayOptions::ParseLDrawLine(QTextStream& LineStream)
{
QString Token;
Expand Down
19 changes: 9 additions & 10 deletions common/lc_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,18 @@ class lcModelProperties
class lcPOVRayOptions
{
public:
lcPOVRayOptions();
void ParseLDrawLine(QTextStream& LineStream);
void SaveLDraw(QTextStream& Stream) const;

bool UseLGEO;
bool ExcludeFloor;
bool ExcludeBackground;
bool NoReflection;
bool NoShadow;
int FloorAxis;
float FloorAmbient;
float FloorDiffuse;
lcVector3 FloorColor;
bool UseLGEO = false;
bool ExcludeFloor = false;
bool ExcludeBackground = false;
bool NoReflection = false;
bool NoShadow = false;
int FloorAxis = 1;
float FloorAmbient = 0.4f;
float FloorDiffuse = 0.4f;
lcVector3 FloorColor = lcVector3(0.8f,0.8f,0.8f);
QString HeaderIncludeFile;
QString FooterIncludeFile;
};
Expand Down
152 changes: 74 additions & 78 deletions common/lc_propertieswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,99 +266,100 @@ void lcPropertiesWidget::FloatChanged()

// todo: mouse drag

if (Piece || Light)
if (PropertyId == lcObjectPropertyId::ObjectPositionX || PropertyId == lcObjectPropertyId::ObjectPositionY || PropertyId == lcObjectPropertyId::ObjectPositionZ)
{
if (PropertyId == lcObjectPropertyId::ObjectPositionX || PropertyId == lcObjectPropertyId::ObjectPositionY || PropertyId == lcObjectPropertyId::ObjectPositionZ)
{
lcVector3 Center;
lcMatrix33 RelativeRotation;
Model->GetMoveRotateTransform(Center, RelativeRotation);
lcVector3 Position = Center;
lcVector3 Center;
lcMatrix33 RelativeRotation;
Model->GetMoveRotateTransform(Center, RelativeRotation);
lcVector3 Position = Center;

if (PropertyId == lcObjectPropertyId::ObjectPositionX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectPositionY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectPositionZ)
Position[2] = Value;
if (PropertyId == lcObjectPropertyId::ObjectPositionX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectPositionY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectPositionZ)
Position[2] = Value;

lcVector3 Distance = Position - Center;
lcVector3 Distance = Position - Center;

Model->MoveSelectedObjects(Distance, Distance, false, true, true, true);
}
else if (PropertyId == lcObjectPropertyId::ObjectRotationX || PropertyId == lcObjectPropertyId::ObjectRotationY || PropertyId == lcObjectPropertyId::ObjectRotationZ)
{
lcVector3 InitialRotation(0.0f, 0.0f, 0.0f);
Model->MoveSelectedObjects(Distance, Distance, false, true, true, true);
}
else if (PropertyId == lcObjectPropertyId::ObjectRotationX || PropertyId == lcObjectPropertyId::ObjectRotationY || PropertyId == lcObjectPropertyId::ObjectRotationZ)
{
lcVector3 InitialRotation(0.0f, 0.0f, 0.0f);

if (Piece)
InitialRotation = lcMatrix44ToEulerAngles(Piece->mModelWorld) * LC_RTOD;
else if (Light)
InitialRotation = lcMatrix44ToEulerAngles(Light->GetWorldMatrix()) * LC_RTOD;
if (Piece)
InitialRotation = lcMatrix44ToEulerAngles(Piece->mModelWorld) * LC_RTOD;
else if (Light)
InitialRotation = lcMatrix44ToEulerAngles(Light->GetWorldMatrix()) * LC_RTOD;

lcVector3 Rotation = InitialRotation;
lcVector3 Rotation = InitialRotation;

if (PropertyId == lcObjectPropertyId::ObjectRotationX)
Rotation[0] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectRotationY)
Rotation[1] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectRotationZ)
Rotation[2] = Value;
if (PropertyId == lcObjectPropertyId::ObjectRotationX)
Rotation[0] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectRotationY)
Rotation[1] = Value;
else if (PropertyId == lcObjectPropertyId::ObjectRotationZ)
Rotation[2] = Value;

Model->RotateSelectedObjects(Rotation - InitialRotation, true, false, true, true);
}
Model->RotateSelectedObjects(Rotation - InitialRotation, true, false, true, true);
}
else if ( Piece || Light )
{
Model->SetObjectsProperty(mFocusObject ? std::vector<lcObject*>{ mFocusObject } : mSelection, PropertyId, Value);
}

if (Camera)
if (PropertyId == lcObjectPropertyId::CameraPositionX || PropertyId == lcObjectPropertyId::CameraPositionY || PropertyId == lcObjectPropertyId::CameraPositionZ)
{
if (PropertyId == lcObjectPropertyId::CameraPositionX || PropertyId == lcObjectPropertyId::CameraPositionY || PropertyId == lcObjectPropertyId::CameraPositionZ)
{
lcVector3 Center = Camera->mPosition;
lcVector3 Position = Center;
lcVector3 Center = Camera->mPosition;
lcVector3 Position = Center;

if (PropertyId == lcObjectPropertyId::CameraPositionX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraPositionY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraPositionZ)
Position[2] = Value;
if (PropertyId == lcObjectPropertyId::CameraPositionX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraPositionY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraPositionZ)
Position[2] = Value;

lcVector3 Distance = Position - Center;
lcVector3 Distance = Position - Center;

Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (PropertyId == lcObjectPropertyId::CameraTargetX || PropertyId == lcObjectPropertyId::CameraTargetY || PropertyId == lcObjectPropertyId::CameraTargetZ)
{
lcVector3 Center = Camera->mTargetPosition;
lcVector3 Position = Center;
Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (PropertyId == lcObjectPropertyId::CameraTargetX || PropertyId == lcObjectPropertyId::CameraTargetY || PropertyId == lcObjectPropertyId::CameraTargetZ)
{
lcVector3 Center = Camera->mTargetPosition;
lcVector3 Position = Center;

if (PropertyId == lcObjectPropertyId::CameraTargetX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraTargetY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraTargetZ)
Position[2] = Value;
if (PropertyId == lcObjectPropertyId::CameraTargetX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraTargetY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraTargetZ)
Position[2] = Value;

lcVector3 Distance = Position - Center;
lcVector3 Distance = Position - Center;

Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (PropertyId == lcObjectPropertyId::CameraUpX || PropertyId == lcObjectPropertyId::CameraUpY || PropertyId == lcObjectPropertyId::CameraUpZ)
{
lcVector3 Center = Camera->mUpVector;
lcVector3 Position = Center;
Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (PropertyId == lcObjectPropertyId::CameraUpX || PropertyId == lcObjectPropertyId::CameraUpY || PropertyId == lcObjectPropertyId::CameraUpZ)
{
lcVector3 Center = Camera->mUpVector;
lcVector3 Position = Center;

if (PropertyId == lcObjectPropertyId::CameraUpX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraUpY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraUpZ)
Position[2] = Value;
if (PropertyId == lcObjectPropertyId::CameraUpX)
Position[0] = Value;
else if (PropertyId == lcObjectPropertyId::CameraUpY)
Position[1] = Value;
else if (PropertyId == lcObjectPropertyId::CameraUpZ)
Position[2] = Value;

lcVector3 Distance = Position - Center;
lcVector3 Distance = Position - Center;

Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (PropertyId == lcObjectPropertyId::CameraFOV)
Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
}
else if (Camera)
{
if (PropertyId == lcObjectPropertyId::CameraFOV)
{
Model->SetCameraFOV(Camera, Value);
}
Expand All @@ -371,11 +372,6 @@ void lcPropertiesWidget::FloatChanged()
Model->SetCameraZFar(Camera, Value);
}
}

if (Light)
{
Model->SetObjectsProperty(mFocusObject ? std::vector<lcObject*>{ mFocusObject } : mSelection, PropertyId, Value);
}
}

void lcPropertiesWidget::UpdateFloat(lcObjectPropertyId PropertyId, float Value)
Expand Down

0 comments on commit 0ded25b

Please sign in to comment.