|
@@ -10,10 +10,7 @@
|
|
|
|
|
|
|
|
namespace BansheeEngine
|
|
namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
- /**
|
|
|
|
|
- * @brief Light type that determines how is light information parsed
|
|
|
|
|
- * by the renderer and other systems.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Light type that determines how is light information parsed by the renderer and other systems. */
|
|
|
enum class LightType
|
|
enum class LightType
|
|
|
{
|
|
{
|
|
|
Directional,
|
|
Directional,
|
|
@@ -21,9 +18,7 @@ namespace BansheeEngine
|
|
|
Spot
|
|
Spot
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Signals which portion of a LightInternal is dirty.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Signals which portion of a LightInternal is dirty. */
|
|
|
enum class LightDirtyFlag
|
|
enum class LightDirtyFlag
|
|
|
{
|
|
{
|
|
|
Transform = 0x01,
|
|
Transform = 0x01,
|
|
@@ -31,8 +26,7 @@ namespace BansheeEngine
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Illuminates a portion of the scene covered by a light. Base class for both sim and core
|
|
|
|
|
- * thread Light implementations.
|
|
|
|
|
|
|
+ * Illuminates a portion of the scene covered by a light. Base class for both sim and core thread Light implementations.
|
|
|
*/
|
|
*/
|
|
|
class BS_EXPORT LightBase
|
|
class BS_EXPORT LightBase
|
|
|
{
|
|
{
|
|
@@ -43,135 +37,101 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
virtual ~LightBase() { }
|
|
virtual ~LightBase() { }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the position of the light, in world space.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the position of the light, in world space. */
|
|
|
Vector3 getPosition() const { return mPosition; }
|
|
Vector3 getPosition() const { return mPosition; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets the position of the light, in world space.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets the position of the light, in world space. */
|
|
|
void setPosition(const Vector3& position) { mPosition = position; _markCoreDirty(); updateBounds(); }
|
|
void setPosition(const Vector3& position) { mPosition = position; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the rotation of the light, in world space.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the rotation of the light, in world space. */
|
|
|
Quaternion getRotation() const { return mRotation; }
|
|
Quaternion getRotation() const { return mRotation; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets the rotation of the light, in world space.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets the rotation of the light, in world space. */
|
|
|
void setRotation(const Quaternion& rotation) { mRotation = rotation; _markCoreDirty(); updateBounds(); }
|
|
void setRotation(const Quaternion& rotation) { mRotation = rotation; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the type of the light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the type of the light. */
|
|
|
LightType getType() const { return mType; }
|
|
LightType getType() const { return mType; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Changes the type of the light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Changes the type of the light. */
|
|
|
void setType(LightType type) { mType = type; _markCoreDirty(); updateBounds(); }
|
|
void setType(LightType type) { mType = type; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Checks does this light cast shadows when rendered.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Checks does this light cast shadows when rendered. */
|
|
|
bool getCastsShadow() const { return mCastsShadows; }
|
|
bool getCastsShadow() const { return mCastsShadows; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets whether this light will cast shadows when rendered.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets whether this light will cast shadows when rendered. */
|
|
|
void setCastsShadow(bool castsShadow) { mCastsShadows = castsShadow; _markCoreDirty(); }
|
|
void setCastsShadow(bool castsShadow) { mCastsShadows = castsShadow; _markCoreDirty(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the color emitted from the light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the color emitted from the light. */
|
|
|
Color getColor() const { return mColor; }
|
|
Color getColor() const { return mColor; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets the color emitted from the light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets the color emitted from the light. */
|
|
|
void setColor(const Color& color) { mColor = color; _markCoreDirty(); }
|
|
void setColor(const Color& color) { mColor = color; _markCoreDirty(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the maximum range of the light. Light will not affect any geometry past that point.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the maximum range of the light. Light will not affect any geometry past that point. */
|
|
|
float getRange() const { return mRange; }
|
|
float getRange() const { return mRange; }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the maximum range of the light. Light will not affect any geometry past that point.
|
|
|
|
|
|
|
+ * Returns the maximum range of the light. Light will not affect any geometry past that point.
|
|
|
*
|
|
*
|
|
|
* @note Normally you want to set this at a point where light intensity is too low due to attenuation.
|
|
* @note Normally you want to set this at a point where light intensity is too low due to attenuation.
|
|
|
*/
|
|
*/
|
|
|
void setRange(float range) { mRange = range; _markCoreDirty(); updateBounds(); }
|
|
void setRange(float range) { mRange = range; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Gets the power of the light source. This is luminous flux for point & spot lights,
|
|
|
|
|
- * and radiance for directional lights.
|
|
|
|
|
|
|
+ * Gets the power of the light source. This is luminous flux for point & spot lights, and radiance for directional
|
|
|
|
|
+ * lights.
|
|
|
*/
|
|
*/
|
|
|
float getIntensity() const { return mIntensity; }
|
|
float getIntensity() const { return mIntensity; }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the power of the light source. This will be luminous flux for point & spot lights,
|
|
|
|
|
- * and radiance for directional lights.
|
|
|
|
|
|
|
+ * Sets the power of the light source. This will be luminous flux for point & spot lights, and radiance for
|
|
|
|
|
+ * directional lights.
|
|
|
*/
|
|
*/
|
|
|
void setIntensity(float intensity) { mIntensity = intensity; _markCoreDirty(); }
|
|
void setIntensity(float intensity) { mIntensity = intensity; _markCoreDirty(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Gets the total angle covered by a spot light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Gets the total angle covered by a spot light. */
|
|
|
Degree getSpotAngle() const { return mSpotAngle; }
|
|
Degree getSpotAngle() const { return mSpotAngle; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets the total angle covered by a spot light.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets the total angle covered by a spot light. */
|
|
|
void setSpotAngle(const Degree& spotAngle) { mSpotAngle = spotAngle; _markCoreDirty(); updateBounds(); }
|
|
void setSpotAngle(const Degree& spotAngle) { mSpotAngle = spotAngle; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Gets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
|
|
|
|
|
- * starts linearly falling off as the angle approaches the total spot angle.
|
|
|
|
|
|
|
+ * Gets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
|
|
|
|
|
+ * starts quadratically falling off as the angle approaches the total spot angle.
|
|
|
*/
|
|
*/
|
|
|
Degree getSpotFalloffAngle() const { return mSpotFalloffAngle; }
|
|
Degree getSpotFalloffAngle() const { return mSpotFalloffAngle; }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
|
|
|
|
|
- * starts linearly falling off as the angle approaches the total spot angle.
|
|
|
|
|
|
|
+ * Sets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
|
|
|
|
|
+ * starts quadratically falling off as the angle approaches the total spot angle.
|
|
|
*/
|
|
*/
|
|
|
- void setSpotFalloffAngle(const Degree& spotFallofAngle) { mSpotFalloffAngle = spotFallofAngle; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
+ void setSpotFalloffAngle(const Degree& spotFallofAngle)
|
|
|
|
|
+ { mSpotFalloffAngle = spotFallofAngle; _markCoreDirty(); updateBounds(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns world space bounds that completely encompass the light's area of influence.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns world space bounds that completely encompass the light's area of influence. */
|
|
|
Sphere getBounds() const { return mBounds; }
|
|
Sphere getBounds() const { return mBounds; }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the radiance of the light source. This is the value that should be used in lighting equations.
|
|
|
|
|
|
|
+ * Returns the radiance of the light source. This is the value that should be used in lighting equations.
|
|
|
*
|
|
*
|
|
|
- * @note Ignores the light direction, therefore caller must ensure to properly handle non-uniform emitters like spot lights
|
|
|
|
|
|
|
+ * @note
|
|
|
|
|
+ * Ignores the light direction, therefore caller must ensure to properly handle non-uniform emitters like spot
|
|
|
|
|
+ * lights.
|
|
|
*/
|
|
*/
|
|
|
float getRadiance() const;
|
|
float getRadiance() const;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Checks whether the light should be rendered or not.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Checks whether the light should be rendered or not. */
|
|
|
bool getIsActive() const { return mIsActive; }
|
|
bool getIsActive() const { return mIsActive; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets whether the light should be rendered or not.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets whether the light should be rendered or not. */
|
|
|
void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
|
|
void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::markCoreDirty
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObject::markCoreDirty */
|
|
|
virtual void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) { }
|
|
virtual void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) { }
|
|
|
|
|
|
|
|
protected:
|
|
protected:
|
|
|
- /**
|
|
|
|
|
- * @brief Updates the internal bounds for the light. Call this whenever a property affecting
|
|
|
|
|
- * the bounds changes.
|
|
|
|
|
- */
|
|
|
|
|
- virtual void updateBounds();
|
|
|
|
|
|
|
+ /** Updates the internal bounds for the light. Call this whenever a property affecting the bounds changes. */
|
|
|
|
|
+ void updateBounds();
|
|
|
|
|
|
|
|
Vector3 mPosition; /**< World space position. */
|
|
Vector3 mPosition; /**< World space position. */
|
|
|
Quaternion mRotation; /**< World space rotation. */
|
|
Quaternion mRotation; /**< World space rotation. */
|
|
@@ -188,7 +148,7 @@ namespace BansheeEngine
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Core thread usable version of a light.
|
|
|
|
|
|
|
+ * Core thread usable version of a light.
|
|
|
*
|
|
*
|
|
|
* @see LightBase
|
|
* @see LightBase
|
|
|
*/
|
|
*/
|
|
@@ -197,20 +157,14 @@ namespace BansheeEngine
|
|
|
public:
|
|
public:
|
|
|
~LightCore();
|
|
~LightCore();
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets an ID that can be used for uniquely identifying this object by the renderer.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets an ID that can be used for uniquely identifying this object by the renderer. */
|
|
|
void setRendererId(UINT32 id) { mRendererId = id; }
|
|
void setRendererId(UINT32 id) { mRendererId = id; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Retrieves an ID that can be used for uniquely identifying this object by the renderer.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Retrieves an ID that can be used for uniquely identifying this object by the renderer. */
|
|
|
UINT32 getRendererId() const { return mRendererId; }
|
|
UINT32 getRendererId() const { return mRendererId; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns a mesh that represents the light's bounds.
|
|
|
|
|
- */
|
|
|
|
|
- SPtr<MeshCore> getMesh() const { return mMesh; }
|
|
|
|
|
|
|
+ /** Returns a mesh that represents the light's bounds. */
|
|
|
|
|
+ SPtr<MeshCore> getMesh() const;
|
|
|
|
|
|
|
|
static const UINT32 LIGHT_CONE_NUM_SIDES;
|
|
static const UINT32 LIGHT_CONE_NUM_SIDES;
|
|
|
static const UINT32 LIGHT_CONE_NUM_SLICES;
|
|
static const UINT32 LIGHT_CONE_NUM_SLICES;
|
|
@@ -220,77 +174,52 @@ namespace BansheeEngine
|
|
|
LightCore(LightType type, Color color, float intensity,
|
|
LightCore(LightType type, Color color, float intensity,
|
|
|
float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
|
|
float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObjectCore::initialize
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObjectCore::initialize */
|
|
|
void initialize() override;
|
|
void initialize() override;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::syncToCore
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObject::syncToCore */
|
|
|
void syncToCore(const CoreSyncData& data) override;
|
|
void syncToCore(const CoreSyncData& data) override;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::updateBounds
|
|
|
|
|
- */
|
|
|
|
|
- void updateBounds() override;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Generates a mesh that represents the light's bounds. Uses current light properties
|
|
|
|
|
- * for determining the mesh type and size.
|
|
|
|
|
- */
|
|
|
|
|
- void generateMesh();
|
|
|
|
|
-
|
|
|
|
|
UINT32 mRendererId;
|
|
UINT32 mRendererId;
|
|
|
SPtr<MeshCore> mMesh;
|
|
SPtr<MeshCore> mMesh;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sim thread usable version of a light.
|
|
|
|
|
|
|
+ * Sim thread usable version of a light.
|
|
|
*
|
|
*
|
|
|
* @see LightBase
|
|
* @see LightBase
|
|
|
*/
|
|
*/
|
|
|
class BS_EXPORT Light : public IReflectable, public CoreObject, public LightBase
|
|
class BS_EXPORT Light : public IReflectable, public CoreObject, public LightBase
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- /**
|
|
|
|
|
- * @brief Retrieves an implementation of a light usable only from the core thread.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Retrieves an implementation of a light usable only from the core thread. */
|
|
|
SPtr<LightCore> getCore() const;
|
|
SPtr<LightCore> getCore() const;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the hash value that can be used to identify if the internal data needs an update.
|
|
|
|
|
- *
|
|
|
|
|
- * @note Internal method.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Returns the hash value that can be used to identify if the internal data needs an update. */
|
|
|
UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
|
|
UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets the hash value that can be used to identify if the internal data needs an update.
|
|
|
|
|
- *
|
|
|
|
|
- * @note Internal method.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Sets the hash value that can be used to identify if the internal data needs an update. */
|
|
|
void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
|
|
void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Updates internal transform values from the specified scene object, in case that scene
|
|
|
|
|
- * object's transform changed since the last call.
|
|
|
|
|
|
|
+ * Updates internal transform values from the specified scene object, in case that scene object's transform changed
|
|
|
|
|
+ * since the last call.
|
|
|
*
|
|
*
|
|
|
* @note Assumes the same scene object will be provided every time.
|
|
* @note Assumes the same scene object will be provided every time.
|
|
|
*/
|
|
*/
|
|
|
void _updateTransform(const HSceneObject& parent);
|
|
void _updateTransform(const HSceneObject& parent);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Creates a new light with provided settings.
|
|
|
|
|
|
|
+ * Creates a new light with provided settings.
|
|
|
*
|
|
*
|
|
|
- * @param type Type of light that determines how are the rest of the parameters interpreted.
|
|
|
|
|
- * @param color Color of the light.
|
|
|
|
|
- * @param intensity Power of the light source. This will be luminous flux for point & spot lights,
|
|
|
|
|
- * and radiance for directional lights.
|
|
|
|
|
- * @param range Cut off range for the light when rendering.
|
|
|
|
|
- * @param castsShadows Determines whether the light casts shadows.
|
|
|
|
|
- * @param spotAngle Total angle covered by a spot light.
|
|
|
|
|
- * @param spotFalloffAngle Spot light angle at which falloff starts. Must be smaller than total angle.
|
|
|
|
|
|
|
+ * @param[in] type Type of light that determines how are the rest of the parameters interpreted.
|
|
|
|
|
+ * @param[in] color Color of the light.
|
|
|
|
|
+ * @param[in] intensity Power of the light source. This will be luminous flux for point & spot lights,
|
|
|
|
|
+ * and radiance for directional lights.
|
|
|
|
|
+ * @param[in] range Cut off range for the light when rendering.
|
|
|
|
|
+ * @param[in] castsShadows Determines whether the light casts shadows.
|
|
|
|
|
+ * @param[in] spotAngle Total angle covered by a spot light.
|
|
|
|
|
+ * @param[in] spotFalloffAngle Spot light angle at which falloff starts. Must be smaller than total angle.
|
|
|
*/
|
|
*/
|
|
|
static SPtr<Light> create(LightType type = LightType::Point, Color color = Color::White,
|
|
static SPtr<Light> create(LightType type = LightType::Point, Color color = Color::White,
|
|
|
float intensity = 100.0f, float range = 10.0f, bool castsShadows = false,
|
|
float intensity = 100.0f, float range = 10.0f, bool castsShadows = false,
|
|
@@ -300,24 +229,16 @@ namespace BansheeEngine
|
|
|
Light(LightType type, Color color, float intensity, float range,
|
|
Light(LightType type, Color color, float intensity, float range,
|
|
|
bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
|
|
bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::createCore
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObject::createCore */
|
|
|
SPtr<CoreObjectCore> createCore() const override;
|
|
SPtr<CoreObjectCore> createCore() const override;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::markCoreDirty
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObject::markCoreDirty */
|
|
|
void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) override;
|
|
void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) override;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @copydoc CoreObject::syncToCore
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** @copydoc CoreObject::syncToCore */
|
|
|
CoreSyncData syncToCore(FrameAlloc* allocator) override;
|
|
CoreSyncData syncToCore(FrameAlloc* allocator) override;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Creates a light with without initializing it. Used for serialization.
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** Creates a light with without initializing it. Used for serialization. */
|
|
|
static SPtr<Light> createEmpty();
|
|
static SPtr<Light> createEmpty();
|
|
|
|
|
|
|
|
UINT32 mLastUpdateHash;
|
|
UINT32 mLastUpdateHash;
|