mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Renamed shadowless to cast shadow.
This commit is contained in:
parent
9648dbb977
commit
080a418e1b
7 changed files with 61 additions and 45 deletions
|
@ -3136,6 +3136,19 @@ void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
|||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
||||
{
|
||||
if (Light->GetCastShadow() == CastShadow)
|
||||
return;
|
||||
|
||||
Light->SetCastShadow(CastShadow);
|
||||
Light->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint(tr("Changing Light Shadow"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightName(lcLight* Light, const QString &Name)
|
||||
{
|
||||
if (Light->GetName() == Name)
|
||||
|
|
|
@ -370,6 +370,7 @@ public:
|
|||
|
||||
void SetLightType(lcLight* Light, lcLightType LightType);
|
||||
void SetLightColor(lcLight* Light, const lcVector3& Color);
|
||||
void SetLightCastShadow(lcLight* Light, bool CastShadow);
|
||||
void SetLightName(lcLight* Light, const QString& Name);
|
||||
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);
|
||||
|
||||
|
|
|
@ -42,9 +42,7 @@ lcLight::lcLight(const lcVector3& Position, const lcVector3& TargetPosition, lcL
|
|||
}
|
||||
|
||||
mPOVRayLight = false;
|
||||
mShadowless = false;
|
||||
mEnableCutoff = false;
|
||||
mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||
mAttenuation = lcVector3(1.0f, 0.0f, 0.0f);
|
||||
mLightFactor[0] = LightType == lcLightType::Directional ? 11.4f : 0.25f;
|
||||
mLightFactor[1] = LightType == lcLightType::Area ? 0.25f : LightType == lcLightType::Spot ? 0.150f : 0.0f;
|
||||
|
@ -108,7 +106,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
|||
if (mPOVRayLight)
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT POV_RAY") << LineEnding;
|
||||
|
||||
if (mShadowless)
|
||||
if (!mCastShadow)
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHADOWLESS") << LineEnding;
|
||||
|
||||
if (mPositionKeys.GetSize() > 1)
|
||||
|
@ -485,7 +483,7 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
|||
}
|
||||
else if (Token == QLatin1String("SHADOWLESS"))
|
||||
{
|
||||
mShadowless = true;
|
||||
mCastShadow = false;
|
||||
}
|
||||
else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY")))
|
||||
mSpotExponentKeys.LoadKeysLDraw(Stream);
|
||||
|
@ -609,9 +607,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
|
|||
mLightSpecular = Props.mLightSpecular;
|
||||
mLightSpecularKeys.ChangeKey(mLightSpecular, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_SHADOWLESS:
|
||||
mShadowless = Props.mShadowless;
|
||||
break;
|
||||
case LC_LIGHT_EXPONENT:
|
||||
if (Props.mPOVRayLight)
|
||||
{
|
||||
|
@ -877,6 +872,11 @@ void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
|
|||
mColorKeys.ChangeKey(Color, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetCastShadow(bool CastShadow)
|
||||
{
|
||||
mCastShadow = CastShadow;
|
||||
}
|
||||
|
||||
void lcLight::InsertTime(lcStep Start, lcStep Time)
|
||||
{
|
||||
mPositionKeys.InsertTime(Start, Time);
|
||||
|
|
|
@ -48,7 +48,6 @@ enum lcLightProperty
|
|||
LC_LIGHT_FACTOR,
|
||||
LC_LIGHT_DIFFUSE,
|
||||
LC_LIGHT_SPECULAR,
|
||||
LC_LIGHT_SHADOWLESS,
|
||||
LC_LIGHT_EXPONENT,
|
||||
LC_LIGHT_AREA_GRID,
|
||||
LC_LIGHT_SPOT_SIZE,
|
||||
|
@ -71,7 +70,6 @@ struct lcLightProperties
|
|||
float mSpotTightness;
|
||||
float mSpotSize;
|
||||
bool mEnableCutoff;
|
||||
bool mShadowless;
|
||||
bool mPOVRayLight;
|
||||
int mLightShape;
|
||||
};
|
||||
|
@ -323,6 +321,13 @@ public:
|
|||
return mColor;
|
||||
}
|
||||
|
||||
void SetCastShadow(bool CastShadow);
|
||||
|
||||
bool GetCastShadow() const
|
||||
{
|
||||
return mCastShadow;
|
||||
}
|
||||
|
||||
void SetName(const QString& Name)
|
||||
{
|
||||
mName = Name;
|
||||
|
@ -352,7 +357,6 @@ public:
|
|||
props.mSpotSize = mSpotSize;
|
||||
props.mPOVRayLight = mPOVRayLight;
|
||||
props.mEnableCutoff = mEnableCutoff;
|
||||
props.mShadowless = mShadowless;
|
||||
props.mAreaGrid = mAreaGrid;
|
||||
props.mLightShape = mLightShape;
|
||||
return props;
|
||||
|
@ -373,7 +377,6 @@ public:
|
|||
bool mHeightSet;
|
||||
bool mEnableCutoff;
|
||||
bool mPOVRayLight;
|
||||
bool mShadowless;
|
||||
float mLightDiffuse;
|
||||
float mLightSpecular;
|
||||
float mSpotSize;
|
||||
|
@ -385,8 +388,23 @@ public:
|
|||
QString mName;
|
||||
|
||||
protected:
|
||||
lcVector3 mColor;
|
||||
void DrawPointLight(lcContext* Context) const;
|
||||
void DrawSpotLight(lcContext* Context) const;
|
||||
void DrawDirectionalLight(lcContext* Context) const;
|
||||
void DrawAreaLight(lcContext* Context) const;
|
||||
|
||||
float SetupLightMatrix(lcContext* Context) const;
|
||||
void DrawSphere(lcContext* Context, float Radius) const;
|
||||
void DrawCylinder(lcContext* Context, float Radius, float Height) const;
|
||||
void DrawTarget(lcContext* Context, float TargetDistance) const;
|
||||
void DrawCone(lcContext* Context, float TargetDistance) const;
|
||||
|
||||
quint32 mState;
|
||||
lcLightType mLightType;
|
||||
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||
bool mCastShadow = true;
|
||||
|
||||
int mLightShape;
|
||||
lcObjectKeyArray<lcVector3> mPositionKeys;
|
||||
lcObjectKeyArray<lcVector3> mTargetPositionKeys;
|
||||
lcObjectKeyArray<lcVector3> mUpVectorKeys;
|
||||
|
@ -402,19 +420,4 @@ protected:
|
|||
lcObjectKeyArray<float> mSpotFalloffKeys;
|
||||
lcObjectKeyArray<float> mSpotExponentKeys;
|
||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||
|
||||
void DrawPointLight(lcContext* Context) const;
|
||||
void DrawSpotLight(lcContext* Context) const;
|
||||
void DrawDirectionalLight(lcContext* Context) const;
|
||||
void DrawAreaLight(lcContext* Context) const;
|
||||
|
||||
float SetupLightMatrix(lcContext* Context) const;
|
||||
void DrawSphere(lcContext* Context, float Radius) const;
|
||||
void DrawCylinder(lcContext* Context, float Radius, float Height) const;
|
||||
void DrawTarget(lcContext* Context, float TargetDistance) const;
|
||||
void DrawCone(lcContext* Context, float TargetDistance) const;
|
||||
|
||||
quint32 mState;
|
||||
lcLightType mLightType;
|
||||
int mLightShape;
|
||||
};
|
||||
|
|
|
@ -2174,7 +2174,7 @@ bool Project::ExportPOVRay(const QString& FileName)
|
|||
const lcVector3& Location = Light->mPosition;
|
||||
const QString LightName = QString(Light->mName).replace(" ","_");
|
||||
LightType = Light->GetLightType();
|
||||
Shadowless = static_cast<int>(Light->mShadowless);
|
||||
Shadowless = Light->GetCastShadow() ? 0 : 1;
|
||||
LightColor = Light->GetColor();
|
||||
Power = Light->mPOVRayExponent;
|
||||
switch(LightType)
|
||||
|
|
|
@ -686,16 +686,15 @@ void lcQPropertiesTree::slotToggled(bool Value)
|
|||
|
||||
if (Light)
|
||||
{
|
||||
lcLightProperties Props = Light->GetLightProperties();
|
||||
if (Item == lightEnableCutoff)
|
||||
{
|
||||
lcLightProperties Props = Light->GetLightProperties();
|
||||
Props.mEnableCutoff = Value;
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_USE_CUTOFF);
|
||||
}
|
||||
else if (Item == lightShadowless)
|
||||
else if (Item == mLightCastShadowItem)
|
||||
{
|
||||
Props.mShadowless = Value;
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_SHADOWLESS);
|
||||
Model->SetLightCastShadow(Light, Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1196,7 @@ void lcQPropertiesTree::SetEmpty()
|
|||
lightSpotSize = nullptr;
|
||||
lightShape = nullptr;
|
||||
lightFormat = nullptr;
|
||||
lightShadowless = nullptr;
|
||||
mLightCastShadowItem = nullptr;
|
||||
lightAreaGridRows = nullptr;
|
||||
lightAreaGridColumns = nullptr;
|
||||
lightSpotFalloff = nullptr;
|
||||
|
@ -1449,7 +1448,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
float Exponent = 0.0f;
|
||||
bool EnableCutoff = false;
|
||||
bool POVRayLight = false;
|
||||
bool Shadowless = false;
|
||||
bool CastShadow = true;
|
||||
PropertyType TargetProperty = PropertyFloat;
|
||||
PropertyType SpotSizeProperty = PropertyFloatLightSpotSize;
|
||||
lcVector3 Position(0.0f, 0.0f, 0.0f);
|
||||
|
@ -1466,7 +1465,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
FormatIndex = static_cast<int>(POVRayLight);
|
||||
Format = POVRayLight ? QLatin1String("POVRay") : QLatin1String("Blender");
|
||||
|
||||
Shadowless = Light->mShadowless;
|
||||
CastShadow = Light->GetCastShadow();
|
||||
Position = Light->mPosition;
|
||||
Target = Light->mTargetPosition;
|
||||
Color = lcQColorFromVector3(Light->GetColor());
|
||||
|
@ -1578,8 +1577,8 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
mLightNameItem = addProperty(mLightAttributesItem, tr("Name"), PropertyString);
|
||||
mLightTypeItem = addProperty(mLightAttributesItem, tr("Type"), PropertyStringList);
|
||||
mLightColorItem = addProperty(mLightAttributesItem, tr("Color"), PropertyColor);
|
||||
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||
|
||||
lightShadowless = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
||||
|
||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||
|
@ -1691,8 +1690,8 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
mLightTypeItem->setText(1, lcLight::GetLightTypeString(LightType));
|
||||
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
|
||||
|
||||
lightShadowless->setCheckState(1, Shadowless ? Qt::Checked : Qt::Unchecked);
|
||||
lightShadowless->setData(0, PropertyValueRole, Shadowless);
|
||||
mLightCastShadowItem->setCheckState(1, CastShadow ? Qt::Checked : Qt::Unchecked);
|
||||
mLightCastShadowItem->setData(0, PropertyValueRole, CastShadow);
|
||||
|
||||
lightExponent->setText(1, lcFormatValueLocalized(Exponent));
|
||||
lightExponent->setData(0, PropertyValueRole, Exponent);
|
||||
|
|
|
@ -149,7 +149,7 @@ protected:
|
|||
QTreeWidgetItem* lightFactorB;
|
||||
QTreeWidgetItem* mLightNameItem;
|
||||
QTreeWidgetItem* lightFormat;
|
||||
QTreeWidgetItem* lightShadowless;
|
||||
QTreeWidgetItem* mLightCastShadowItem;
|
||||
QTreeWidgetItem* lightAreaGridRows;
|
||||
QTreeWidgetItem* lightAreaGridColumns;
|
||||
QTreeWidgetItem* lightSpotFalloff;
|
||||
|
|
Loading…
Reference in a new issue