Refactor engine to support double-precision vectors
This commit is contained in:
@@ -19,7 +19,7 @@ AnimatedModel::AnimatedModel(const SpawnParams& params)
|
||||
: ModelInstanceActor(params)
|
||||
, _actualMode(AnimationUpdateMode::Never)
|
||||
, _counter(0)
|
||||
, _lastMinDstSqr(MAX_float)
|
||||
, _lastMinDstSqr(MAX_Real)
|
||||
, _lastUpdateFrame(0)
|
||||
{
|
||||
GraphInstance.Object = this;
|
||||
@@ -167,11 +167,11 @@ int32 AnimatedModel::FindClosestNode(const Vector3& location, bool worldSpace) c
|
||||
const_cast<AnimatedModel*>(this)->PreInitSkinningData(); // Ensure to have valid nodes pose to return
|
||||
const Vector3 pos = worldSpace ? _transform.WorldToLocal(location) : location;
|
||||
int32 result = -1;
|
||||
float closest = MAX_float;
|
||||
Real closest = MAX_Real;
|
||||
for (int32 nodeIndex = 0; nodeIndex < GraphInstance.NodesPose.Count(); nodeIndex++)
|
||||
{
|
||||
const Vector3 node = GraphInstance.NodesPose[nodeIndex].GetTranslation();
|
||||
const float dst = Vector3::DistanceSquared(node, pos);
|
||||
const Real dst = Vector3::DistanceSquared(node, pos);
|
||||
if (dst < closest)
|
||||
{
|
||||
closest = dst;
|
||||
@@ -684,10 +684,10 @@ void AnimatedModel::Update()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (updateAnim && (UpdateWhenOffscreen || _lastMinDstSqr < MAX_float))
|
||||
if (updateAnim && (UpdateWhenOffscreen || _lastMinDstSqr < MAX_Real))
|
||||
UpdateAnimation();
|
||||
|
||||
_lastMinDstSqr = MAX_float;
|
||||
_lastMinDstSqr = MAX_Real;
|
||||
}
|
||||
|
||||
void AnimatedModel::Draw(RenderContext& renderContext)
|
||||
@@ -753,7 +753,7 @@ BoundingBox AnimatedModel::GetEditorBox() const
|
||||
|
||||
#endif
|
||||
|
||||
bool AnimatedModel::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool AnimatedModel::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -822,7 +822,7 @@ void AnimatedModel::Deserialize(DeserializeStream& stream, ISerializeModifier* m
|
||||
DrawModes |= DrawPass::GlobalSurfaceAtlas;
|
||||
}
|
||||
|
||||
bool AnimatedModel::IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal)
|
||||
bool AnimatedModel::IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
auto model = SkinnedModel.Get();
|
||||
if (!model || !model->IsInitialized() || model->GetLoadedLODs() == 0)
|
||||
@@ -842,7 +842,7 @@ bool AnimatedModel::IntersectsEntry(int32 entryIndex, const Ray& ray, float& dis
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AnimatedModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex)
|
||||
bool AnimatedModel::IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex)
|
||||
{
|
||||
auto model = SkinnedModel.Get();
|
||||
if (!model || !model->IsInitialized() || model->GetLoadedLODs() == 0)
|
||||
@@ -850,7 +850,7 @@ bool AnimatedModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& no
|
||||
|
||||
// Find mesh in the highest loaded LOD that is using the given material slot index and ray hits it
|
||||
bool result = false;
|
||||
float closest = MAX_float;
|
||||
Real closest = MAX_Real;
|
||||
Vector3 closestNormal = Vector3::Up;
|
||||
int32 closestEntry = -1;
|
||||
auto& meshes = model->LODs[model->HighestResidentLODIndex()].Meshes;
|
||||
@@ -858,7 +858,7 @@ bool AnimatedModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& no
|
||||
{
|
||||
// Test intersection with mesh and check if is closer than previous
|
||||
const auto& mesh = meshes[i];
|
||||
float dst;
|
||||
Real dst;
|
||||
Vector3 nrm;
|
||||
if (mesh.Intersects(ray, _world, dst, nrm) && dst < closest)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
SkinnedMeshDrawData _skinningData;
|
||||
AnimationUpdateMode _actualMode;
|
||||
uint32 _counter;
|
||||
float _lastMinDstSqr;
|
||||
Real _lastMinDstSqr;
|
||||
uint64 _lastUpdateFrame;
|
||||
BlendShapesInstance _blendShapes;
|
||||
ScriptingObjectReference<AnimatedModel> _masterPose;
|
||||
@@ -380,11 +380,11 @@ public:
|
||||
void OnDebugDrawSelected() override;
|
||||
BoundingBox GetEditorBox() const override;
|
||||
#endif
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex) override;
|
||||
bool IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
bool IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -135,9 +135,9 @@ void BoxBrush::SetMaterial(int32 surfaceIndex, MaterialBase* material)
|
||||
OnBrushModified();
|
||||
}
|
||||
|
||||
bool BoxBrush::Intersects(int32 surfaceIndex, const Ray& ray, float& distance, Vector3& normal) const
|
||||
bool BoxBrush::Intersects(int32 surfaceIndex, const Ray& ray, Real& distance, Vector3& normal) const
|
||||
{
|
||||
distance = MAX_float;
|
||||
distance = MAX_Real;
|
||||
normal = Vector3::Up;
|
||||
auto scene = GetScene();
|
||||
CHECK_RETURN(scene, false);
|
||||
@@ -201,12 +201,11 @@ void BoxBrush::Deserialize(DeserializeStream& stream, ISerializeModifier* modifi
|
||||
}
|
||||
}
|
||||
|
||||
bool BoxBrush::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool BoxBrush::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
bool result = false;
|
||||
float minDistance = MAX_float;
|
||||
Real minDistance = MAX_float;
|
||||
Vector3 minDistanceNormal = Vector3::Up;
|
||||
|
||||
if (_bounds.Intersects(ray, distance))
|
||||
{
|
||||
for (int32 surfaceIndex = 0; surfaceIndex < 6; surfaceIndex++)
|
||||
@@ -219,7 +218,6 @@ bool BoxBrush::IntersectsItself(const Ray& ray, float& distance, Vector3& normal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
distance = minDistance;
|
||||
normal = minDistanceNormal;
|
||||
return result;
|
||||
|
||||
@@ -36,13 +36,13 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(BrushSurface);
|
||||
/// The surface texture coordinates scale.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(30), EditorDisplay(\"Brush\", \"UV Scale\"), Limit(-1000, 1000, 0.01f)")
|
||||
Vector2 TexCoordScale = Vector2::One;
|
||||
Float2 TexCoordScale = Float2::One;
|
||||
|
||||
/// <summary>
|
||||
/// The surface texture coordinates offset.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(40), EditorDisplay(\"Brush\", \"UV Offset\"), Limit(-1000, 1000, 0.01f)")
|
||||
Vector2 TexCoordOffset = Vector2::Zero;
|
||||
Float2 TexCoordOffset = Float2::Zero;
|
||||
|
||||
/// <summary>
|
||||
/// The surface texture coordinates rotation angle (in degrees).
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
/// <param name="distance">When the method completes and returns true, contains the distance of the intersection (if any valid).</param>
|
||||
/// <param name="normal">When the method completes, contains the intersection surface normal vector (if any valid).</param>
|
||||
/// <returns>True if the actor is intersected by the ray, otherwise false.</returns>
|
||||
API_FUNCTION() bool Intersects(int32 surfaceIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal) const;
|
||||
API_FUNCTION() bool Intersects(int32 surfaceIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) Real& distance, API_PARAM(Out) Vector3& normal) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush surface triangles array (group by 3 vertices).
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
// [Actor]
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
#if USE_EDITOR
|
||||
void OnDebugDrawSelected() override;
|
||||
#endif
|
||||
|
||||
@@ -104,12 +104,12 @@ void Camera::SetOrthographicScale(float value)
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Vector2& gameWindowSpaceLocation) const
|
||||
void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Float2& gameWindowSpaceLocation) const
|
||||
{
|
||||
ProjectPoint(worldSpaceLocation, gameWindowSpaceLocation, GetViewport());
|
||||
}
|
||||
|
||||
void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Vector2& cameraViewportSpaceLocation, const Viewport& viewport) const
|
||||
void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewportSpaceLocation, const Viewport& viewport) const
|
||||
{
|
||||
Matrix v, p, vp;
|
||||
GetMatrices(v, p, viewport);
|
||||
@@ -117,15 +117,15 @@ void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Vector2& cameraView
|
||||
Vector3 clipSpaceLocation;
|
||||
Vector3::Transform(worldSpaceLocation, vp, clipSpaceLocation);
|
||||
viewport.Project(worldSpaceLocation, vp, clipSpaceLocation);
|
||||
cameraViewportSpaceLocation = Vector2(clipSpaceLocation);
|
||||
cameraViewportSpaceLocation = Float2(clipSpaceLocation);
|
||||
}
|
||||
|
||||
Ray Camera::ConvertMouseToRay(const Vector2& mousePosition) const
|
||||
Ray Camera::ConvertMouseToRay(const Float2& mousePosition) const
|
||||
{
|
||||
return ConvertMouseToRay(mousePosition, GetViewport());
|
||||
}
|
||||
|
||||
Ray Camera::ConvertMouseToRay(const Vector2& mousePosition, const Viewport& viewport) const
|
||||
Ray Camera::ConvertMouseToRay(const Float2& mousePosition, const Viewport& viewport) const
|
||||
{
|
||||
#if 1
|
||||
// Gather camera properties
|
||||
@@ -164,7 +164,7 @@ Ray Camera::ConvertMouseToRay(const Vector2& mousePosition, const Viewport& view
|
||||
|
||||
Viewport Camera::GetViewport() const
|
||||
{
|
||||
Viewport result = Viewport(Vector2::Zero);
|
||||
Viewport result = Viewport(Float2::Zero);
|
||||
|
||||
#if USE_EDITOR
|
||||
// Editor
|
||||
@@ -182,7 +182,7 @@ Viewport Camera::GetViewport() const
|
||||
|
||||
// Fallback to the default value
|
||||
if (result.Width <= ZeroTolerance)
|
||||
result.Size = Vector2(1280, 720);
|
||||
result.Size = Float2(1280, 720);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ void Camera::GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewp
|
||||
}
|
||||
|
||||
// Create view matrix
|
||||
const Vector3 direction = GetDirection();
|
||||
const Float3 direction = GetDirection();
|
||||
const Vector3 target = _transform.Translation + direction;
|
||||
Vector3 up;
|
||||
Vector3::Transform(Vector3::Up, GetOrientation(), up);
|
||||
@@ -237,7 +237,7 @@ BoundingBox Camera::GetEditorBox() const
|
||||
return BoundingBox(pos - size, pos + size);
|
||||
}
|
||||
|
||||
bool Camera::IntersectsItselfEditor(const Ray& ray, float& distance)
|
||||
bool Camera::IntersectsItselfEditor(const Ray& ray, Real& distance)
|
||||
{
|
||||
return _previewModelBox.Intersects(ray, distance);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="worldSpaceLocation">The input world-space location (XYZ in world).</param>
|
||||
/// <param name="gameWindowSpaceLocation">The output game window coordinates (XY in screen pixels).</param>
|
||||
API_FUNCTION() void ProjectPoint(const Vector3& worldSpaceLocation, API_PARAM(Out) Vector2& gameWindowSpaceLocation) const;
|
||||
API_FUNCTION() void ProjectPoint(const Vector3& worldSpaceLocation, API_PARAM(Out) Float2& gameWindowSpaceLocation) const;
|
||||
|
||||
/// <summary>
|
||||
/// Projects the point from 3D world-space to the camera viewport-space (in screen pixels for given viewport).
|
||||
@@ -188,14 +188,14 @@ public:
|
||||
/// <param name="worldSpaceLocation">The input world-space location (XYZ in world).</param>
|
||||
/// <param name="cameraViewportSpaceLocation">The output camera viewport-space location (XY in screen pixels).</param>
|
||||
/// <param name="viewport">The viewport.</param>
|
||||
API_FUNCTION() void ProjectPoint(const Vector3& worldSpaceLocation, API_PARAM(Out) Vector2& cameraViewportSpaceLocation, API_PARAM(Ref) const Viewport& viewport) const;
|
||||
API_FUNCTION() void ProjectPoint(const Vector3& worldSpaceLocation, API_PARAM(Out) Float2& cameraViewportSpaceLocation, API_PARAM(Ref) const Viewport& viewport) const;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the mouse position to 3D ray.
|
||||
/// </summary>
|
||||
/// <param name="mousePosition">The mouse position.</param>
|
||||
/// <returns>Mouse ray</returns>
|
||||
API_FUNCTION() Ray ConvertMouseToRay(const Vector2& mousePosition) const;
|
||||
API_FUNCTION() Ray ConvertMouseToRay(const Float2& mousePosition) const;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the mouse position to 3D ray.
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
/// <param name="mousePosition">The mouse position.</param>
|
||||
/// <param name="viewport">The viewport.</param>
|
||||
/// <returns>Mouse ray</returns>
|
||||
API_FUNCTION() Ray ConvertMouseToRay(const Vector2& mousePosition, API_PARAM(Ref) const Viewport& viewport) const;
|
||||
API_FUNCTION() Ray ConvertMouseToRay(const Float2& mousePosition, API_PARAM(Ref) const Viewport& viewport) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the camera viewport.
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
|
||||
#if USE_EDITOR
|
||||
// Intersection check for editor picking the camera
|
||||
API_FUNCTION() bool IntersectsItselfEditor(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance);
|
||||
API_FUNCTION() bool IntersectsItselfEditor(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) Real& distance);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -81,7 +81,7 @@ void Decal::Draw(RenderContext& renderContext)
|
||||
Material->IsDecal())
|
||||
{
|
||||
const auto lodView = (renderContext.LodProxyView ? renderContext.LodProxyView : &renderContext.View);
|
||||
const float screenRadiusSquared = RenderTools::ComputeBoundsScreenRadiusSquared(_sphere.Center, _sphere.Radius, *lodView) * renderContext.View.ModelLODDistanceFactorSqrt;
|
||||
const float screenRadiusSquared = RenderTools::ComputeBoundsScreenRadiusSquared(_sphere.Center, (float)_sphere.Radius, *lodView) * renderContext.View.ModelLODDistanceFactorSqrt;
|
||||
|
||||
// Check if decal is being culled
|
||||
if (Math::Square(DrawMinScreenSize * 0.5f) > screenRadiusSquared)
|
||||
@@ -115,7 +115,7 @@ void Decal::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
DESERIALIZE(DrawMinScreenSize);
|
||||
}
|
||||
|
||||
bool Decal::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool Decal::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return _bounds.Intersects(ray, distance, normal);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ void DirectionalLight::Draw(RenderContext& renderContext)
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, GetPosition()) < ViewDistance * ViewDistance))
|
||||
{
|
||||
RendererDirectionalLightData data;
|
||||
data.Position = GetPosition();
|
||||
data.Position = GetPosition(); // TODO: large-worlds
|
||||
data.MinRoughness = MinRoughness;
|
||||
data.ShadowsDistance = ShadowsDistance;
|
||||
data.Color = Color.ToVector3() * (Color.A * brightness);
|
||||
data.Color = Color.ToFloat3() * (Color.A * brightness);
|
||||
data.ShadowsStrength = ShadowsStrength;
|
||||
data.Direction = GetDirection();
|
||||
data.ShadowsFadeDistance = ShadowsFadeDistance;
|
||||
@@ -62,7 +62,7 @@ void DirectionalLight::Deserialize(DeserializeStream& stream, ISerializeModifier
|
||||
DESERIALIZE(CascadeCount);
|
||||
}
|
||||
|
||||
bool DirectionalLight::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool DirectionalLight::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
protected:
|
||||
// [LightWithShadow]
|
||||
|
||||
@@ -47,8 +47,8 @@ float EnvironmentProbe::GetScaledRadius() const
|
||||
void EnvironmentProbe::SetupProbeData(ProbeData* data) const
|
||||
{
|
||||
const float radius = GetScaledRadius();
|
||||
data->Data0 = Vector4(GetPosition(), 0);
|
||||
data->Data1 = Vector4(radius, 1.0f / radius, Brightness, 0);
|
||||
data->Data0 = Float4(GetPosition(), 0); // TODO: large-worlds
|
||||
data->Data1 = Float4(radius, 1.0f / radius, Brightness, 0);
|
||||
}
|
||||
|
||||
CubeTexture* EnvironmentProbe::GetCustomProbe() const
|
||||
@@ -195,7 +195,7 @@ bool EnvironmentProbe::HasContentLoaded() const
|
||||
return _probe == nullptr || _probe->IsLoaded();
|
||||
}
|
||||
|
||||
bool EnvironmentProbe::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool EnvironmentProbe::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return CollisionsHelper::RayIntersectsSphere(ray, _sphere, distance, normal);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool HasContentLoaded() const override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -122,14 +122,14 @@ bool ExponentialHeightFog::HasContentLoaded() const
|
||||
return _shader && _shader->IsLoaded();
|
||||
}
|
||||
|
||||
bool ExponentialHeightFog::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool ExponentialHeightFog::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExponentialHeightFog::GetVolumetricFogOptions(VolumetricFogOptions& result) const
|
||||
{
|
||||
const float height = GetPosition().Y;
|
||||
const float height = (float)GetPosition().Y;
|
||||
const float density = FogDensity / 1000.0f;
|
||||
const float heightFalloff = FogHeightFalloff / 1000.0f;
|
||||
|
||||
@@ -139,18 +139,18 @@ void ExponentialHeightFog::GetVolumetricFogOptions(VolumetricFogOptions& result)
|
||||
result.Emissive = VolumetricFogEmissive * (1.0f / 100.0f);
|
||||
result.ExtinctionScale = VolumetricFogExtinctionScale;
|
||||
result.Distance = VolumetricFogDistance;
|
||||
result.FogParameters = Vector4(density, height, heightFalloff, 0.0f);
|
||||
result.FogParameters = Float4(density, height, heightFalloff, 0.0f);
|
||||
}
|
||||
|
||||
void ExponentialHeightFog::GetExponentialHeightFogData(const RenderView& view, ExponentialHeightFogData& result) const
|
||||
{
|
||||
const float height = GetPosition().Y;
|
||||
const float height = (float)GetPosition().Y;
|
||||
const float density = FogDensity / 1000.0f;
|
||||
const float heightFalloff = FogHeightFalloff / 1000.0f;
|
||||
const float viewHeight = view.Position.Y;
|
||||
const bool useDirectionalLightInscattering = DirectionalInscatteringLight != nullptr;
|
||||
|
||||
result.FogInscatteringColor = FogInscatteringColor.ToVector3();
|
||||
result.FogInscatteringColor = FogInscatteringColor.ToFloat3();
|
||||
result.FogMinOpacity = 1.0f - FogMaxOpacity;
|
||||
result.FogDensity = density;
|
||||
result.FogHeight = height;
|
||||
@@ -162,14 +162,14 @@ void ExponentialHeightFog::GetExponentialHeightFogData(const RenderView& view, E
|
||||
if (useDirectionalLightInscattering)
|
||||
{
|
||||
result.InscatteringLightDirection = -DirectionalInscatteringLight->GetDirection();
|
||||
result.DirectionalInscatteringColor = DirectionalInscatteringColor.ToVector3();
|
||||
result.DirectionalInscatteringColor = DirectionalInscatteringColor.ToFloat3();
|
||||
result.DirectionalInscatteringExponent = Math::Clamp(DirectionalInscatteringExponent, 0.000001f, 1000.0f);
|
||||
result.DirectionalInscatteringStartDistance = Math::Min(DirectionalInscatteringStartDistance, view.Far - 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.InscatteringLightDirection = Vector3::Zero;
|
||||
result.DirectionalInscatteringColor = Vector3::Zero;
|
||||
result.InscatteringLightDirection = Float3::Zero;
|
||||
result.DirectionalInscatteringColor = Float3::Zero;
|
||||
result.DirectionalInscatteringExponent = 4.0f;
|
||||
result.DirectionalInscatteringStartDistance = 0.0f;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool HasContentLoaded() const override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
// [IFogRenderer]
|
||||
void GetVolumetricFogOptions(VolumetricFogOptions& result) const override;
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
/// <param name="distance">When the method completes and returns true, contains the distance of the intersection (if any valid).</param>
|
||||
/// <param name="normal">When the method completes, contains the intersection surface normal vector (if any valid).</param>
|
||||
/// <returns>True if the actor is intersected by the ray, otherwise false.</returns>
|
||||
API_FUNCTION() virtual bool IntersectsEntry(int32 entryIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal)
|
||||
API_FUNCTION() virtual bool IntersectsEntry(int32 entryIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) Real& distance, API_PARAM(Out) Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
/// <param name="normal">When the method completes, contains the intersection surface normal vector (if any valid).</param>
|
||||
/// <param name="entryIndex">When the method completes, contains the intersection entry index (if any valid).</param>
|
||||
/// <returns>True if the actor is intersected by the ray, otherwise false.</returns>
|
||||
API_FUNCTION() virtual bool IntersectsEntry(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal, API_PARAM(Out) int32& entryIndex)
|
||||
API_FUNCTION() virtual bool IntersectsEntry(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) Real& distance, API_PARAM(Out) Vector3& normal, API_PARAM(Out) int32& entryIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ PointLight::PointLight(const SpawnParams& params)
|
||||
ShadowsDistance = 2000.0f;
|
||||
ShadowsFadeDistance = 100.0f;
|
||||
ShadowsDepthBias = 0.5f;
|
||||
_direction = Vector3::Forward;
|
||||
_direction = Float3::Forward;
|
||||
_sphere = BoundingSphere(Vector3::Zero, _radius);
|
||||
BoundingBox::FromSphere(_sphere, _box);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ void PointLight::SetRadius(float value)
|
||||
void PointLight::UpdateBounds()
|
||||
{
|
||||
// Cache light direction
|
||||
Vector3::Transform(Vector3::Forward, _transform.Orientation, _direction);
|
||||
Float3::Transform(Float3::Forward, _transform.Orientation, _direction);
|
||||
_direction.Normalize();
|
||||
|
||||
// Cache bounding box
|
||||
@@ -111,10 +111,10 @@ void PointLight::Draw(RenderContext& renderContext)
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, GetPosition()) < ViewDistance * ViewDistance))
|
||||
{
|
||||
RendererPointLightData data;
|
||||
data.Position = GetPosition();
|
||||
data.Position = GetPosition(); // TODO: large-worlds
|
||||
data.MinRoughness = MinRoughness;
|
||||
data.ShadowsDistance = ShadowsDistance;
|
||||
data.Color = Color.ToVector3() * (Color.A * brightness);
|
||||
data.Color = Color.ToFloat3() * (Color.A * brightness);
|
||||
data.ShadowsStrength = ShadowsStrength;
|
||||
data.Direction = _direction;
|
||||
data.ShadowsFadeDistance = ShadowsFadeDistance;
|
||||
@@ -201,7 +201,7 @@ void PointLight::Deserialize(DeserializeStream& stream, ISerializeModifier* modi
|
||||
DESERIALIZE(IESBrightnessScale);
|
||||
}
|
||||
|
||||
bool PointLight::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool PointLight::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return CollisionsHelper::RayIntersectsSphere(ray, _sphere, distance, normal);
|
||||
}
|
||||
|
||||
@@ -11,15 +11,13 @@
|
||||
/// </summary>
|
||||
API_CLASS() class FLAXENGINE_API PointLight : public LightWithShadow
|
||||
{
|
||||
DECLARE_SCENE_OBJECT(PointLight);
|
||||
DECLARE_SCENE_OBJECT(PointLight);
|
||||
private:
|
||||
|
||||
Vector3 _direction;
|
||||
Float3 _direction;
|
||||
float _radius;
|
||||
int32 _sceneRenderingKey = -1;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Light source bulb radius
|
||||
/// </summary>
|
||||
@@ -63,7 +61,6 @@ public:
|
||||
float IESBrightnessScale = 1.0f;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Computes light brightness value
|
||||
/// </summary>
|
||||
@@ -91,11 +88,9 @@ public:
|
||||
API_PROPERTY() void SetRadius(float value);
|
||||
|
||||
private:
|
||||
|
||||
void UpdateBounds();
|
||||
|
||||
public:
|
||||
|
||||
// [LightWithShadow]
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
#if USE_EDITOR
|
||||
@@ -105,10 +100,9 @@ public:
|
||||
void OnLayerChanged() override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
protected:
|
||||
|
||||
// [LightWithShadow]
|
||||
void OnEnable() override;
|
||||
void OnDisable() override;
|
||||
|
||||
@@ -21,11 +21,11 @@ void PostFxVolume::Collect(RenderContext& renderContext)
|
||||
float weight = _blendWeight;
|
||||
if (_isBounded)
|
||||
{
|
||||
float distance;
|
||||
Real distance;
|
||||
if (_bounds.Contains(renderContext.View.Position, &distance) == ContainmentType::Contains)
|
||||
{
|
||||
if (_blendRadius > 0.0f)
|
||||
weight = Math::Saturate(distance / _blendRadius) * weight;
|
||||
weight = Math::Saturate((float)distance / _blendRadius) * weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -67,12 +67,12 @@ void Sky::InitConfig(AtmosphericFogData& config) const
|
||||
if (SunLight)
|
||||
{
|
||||
config.AtmosphericFogSunDirection = -SunLight->GetDirection();
|
||||
config.AtmosphericFogSunColor = SunLight->Color.ToVector3();
|
||||
config.AtmosphericFogSunColor = SunLight->Color.ToFloat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.AtmosphericFogSunDirection = Vector3::UnitY;
|
||||
config.AtmosphericFogSunColor = Vector3::One;
|
||||
config.AtmosphericFogSunDirection = Float3::UnitY;
|
||||
config.AtmosphericFogSunColor = Float3::One;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ bool Sky::HasContentLoaded() const
|
||||
return _shader && _shader->IsLoaded() && AtmospherePreCompute::GetCache(nullptr);
|
||||
}
|
||||
|
||||
bool Sky::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool Sky::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool HasContentLoaded() const override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
// [IAtmosphericFogRenderer]
|
||||
void DrawFog(GPUContext* context, RenderContext& renderContext, GPUTextureView* output) override;
|
||||
|
||||
@@ -106,12 +106,12 @@ void SkyLight::Draw(RenderContext& renderContext)
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, GetPosition()) < ViewDistance * ViewDistance))
|
||||
{
|
||||
RendererSkyLightData data;
|
||||
data.Position = GetPosition();
|
||||
data.Color = Color.ToVector3() * (Color.A * brightness);
|
||||
data.Position = GetPosition(); // TODO: large-worlds
|
||||
data.Color = Color.ToFloat3() * (Color.A * brightness);
|
||||
data.VolumetricScatteringIntensity = VolumetricScatteringIntensity;
|
||||
data.CastVolumetricShadow = CastVolumetricShadow;
|
||||
data.RenderedVolumetricFog = 0;
|
||||
data.AdditiveColor = AdditiveColor.ToVector3() * (AdditiveColor.A * brightness);
|
||||
data.AdditiveColor = AdditiveColor.ToFloat3() * (AdditiveColor.A * brightness);
|
||||
data.Radius = GetScaledRadius();
|
||||
data.Image = GetSource();
|
||||
renderContext.List->SkyLights.Add(data);
|
||||
|
||||
@@ -82,7 +82,7 @@ bool Skybox::HasContentLoaded() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Skybox::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool Skybox::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool HasContentLoaded() const override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
// [ISkyRenderer]
|
||||
void ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world) override;
|
||||
|
||||
@@ -171,7 +171,7 @@ float Spline::GetSplineLength() const
|
||||
Vector3 pos;
|
||||
AnimationUtils::Bezier(a.Value.Translation, leftTangent, rightTangent, b.Value.Translation, t, pos);
|
||||
pos *= _transform.Scale;
|
||||
sum += Vector3::DistanceSquared(pos, prevPoint);
|
||||
sum += (float)Vector3::DistanceSquared(pos, prevPoint);
|
||||
prevPoint = pos;
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace
|
||||
const float t = (float)i * step;
|
||||
Transform result;
|
||||
Spline::Keyframe::Interpolate(start, end, t, length, result);
|
||||
const float distanceSquared = Vector3::DistanceSquared(point, result.Translation);
|
||||
const float distanceSquared = (float)Vector3::DistanceSquared(point, result.Translation);
|
||||
if (distanceSquared < bestDistanceSquared)
|
||||
{
|
||||
bestDistanceSquared = distanceSquared;
|
||||
|
||||
@@ -171,8 +171,8 @@ void SplineModel::OnSplineUpdated()
|
||||
}
|
||||
}
|
||||
}
|
||||
_meshMinZ = localModelBounds.Minimum.Z;
|
||||
_meshMaxZ = localModelBounds.Maximum.Z;
|
||||
_meshMinZ = (float)localModelBounds.Minimum.Z;
|
||||
_meshMaxZ = (float)localModelBounds.Maximum.Z;
|
||||
Transform chunkLocal, chunkWorld, leftTangent, rightTangent;
|
||||
Array<Vector3> segmentPoints;
|
||||
segmentPoints.Resize(chunksPerSegment);
|
||||
@@ -225,7 +225,7 @@ void SplineModel::UpdateDeformationBuffer()
|
||||
const int32 segments = keyframes.Count() - 1;
|
||||
const int32 chunksPerSegment = Math::Clamp(Math::CeilToInt(SPLINE_RESOLUTION * _quality), 2, 1024);
|
||||
const int32 count = (chunksPerSegment * segments + 1) * 3;
|
||||
const uint32 size = count * sizeof(Vector4);
|
||||
const uint32 size = count * sizeof(Float4);
|
||||
if (_deformationBuffer->GetSize() != size)
|
||||
{
|
||||
if (_deformationBufferData)
|
||||
@@ -390,7 +390,7 @@ void SplineModel::Draw(RenderContext& renderContext)
|
||||
}
|
||||
else
|
||||
{
|
||||
lodIndex = RenderTools::ComputeModelLOD(model, instance.Sphere.Center, instance.Sphere.Radius, renderContext);
|
||||
lodIndex = RenderTools::ComputeModelLOD(model, instance.Sphere.Center, (float)instance.Sphere.Radius, renderContext);
|
||||
if (lodIndex == -1)
|
||||
continue;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ void SplineModel::Draw(RenderContext& renderContext)
|
||||
}
|
||||
}
|
||||
|
||||
bool SplineModel::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool SplineModel::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
// [ModelInstanceActor]
|
||||
bool HasContentLoaded() const override;
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
void OnParentChanged() override;
|
||||
|
||||
@@ -161,10 +161,10 @@ void SpotLight::Draw(RenderContext& renderContext)
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, GetPosition()) < ViewDistance * ViewDistance))
|
||||
{
|
||||
RendererSpotLightData data;
|
||||
data.Position = GetPosition();
|
||||
data.Position = GetPosition(); // TODO: large-worlds
|
||||
data.MinRoughness = MinRoughness;
|
||||
data.ShadowsDistance = ShadowsDistance;
|
||||
data.Color = Color.ToVector3() * (Color.A * brightness);
|
||||
data.Color = Color.ToFloat3() * (Color.A * brightness);
|
||||
data.ShadowsStrength = ShadowsStrength;
|
||||
data.Direction = _direction;
|
||||
data.ShadowsFadeDistance = ShadowsFadeDistance;
|
||||
@@ -183,7 +183,7 @@ void SpotLight::Draw(RenderContext& renderContext)
|
||||
data.InvCosConeDifference = _invCosConeDifference;
|
||||
data.ContactShadowsLength = ContactShadowsLength;
|
||||
data.IESTexture = IESTexture ? IESTexture->GetTexture() : nullptr;
|
||||
Vector3::Transform(Vector3::Up, GetOrientation(), data.UpVector);
|
||||
Float3::Transform(Float3::Up, GetOrientation(), data.UpVector);
|
||||
data.OuterConeAngle = outerConeAngle;
|
||||
renderContext.List->SpotLights.Add(data);
|
||||
}
|
||||
@@ -264,7 +264,7 @@ void SpotLight::Deserialize(DeserializeStream& stream, ISerializeModifier* modif
|
||||
DESERIALIZE(IESBrightnessScale);
|
||||
}
|
||||
|
||||
bool SpotLight::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool SpotLight::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
return CollisionsHelper::RayIntersectsSphere(ray, _sphere, distance, normal);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
#endif
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ void StaticModel::Draw(RenderContext& renderContext)
|
||||
GEOMETRY_DRAW_STATE_EVENT_END(_drawState, _world);
|
||||
}
|
||||
|
||||
bool StaticModel::IntersectsItself(const Ray& ray, float& distance, Vector3& normal)
|
||||
bool StaticModel::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -462,7 +462,7 @@ void StaticModel::Deserialize(DeserializeStream& stream, ISerializeModifier* mod
|
||||
}
|
||||
}
|
||||
|
||||
bool StaticModel::IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal)
|
||||
bool StaticModel::IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal)
|
||||
{
|
||||
auto model = Model.Get();
|
||||
if (!model || !model->IsInitialized() || model->GetLoadedLODs() == 0)
|
||||
@@ -482,7 +482,7 @@ bool StaticModel::IntersectsEntry(int32 entryIndex, const Ray& ray, float& dista
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StaticModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex)
|
||||
bool StaticModel::IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex)
|
||||
{
|
||||
auto model = Model.Get();
|
||||
if (!model || !model->IsInitialized() || model->GetLoadedLODs() == 0)
|
||||
@@ -490,7 +490,7 @@ bool StaticModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& norm
|
||||
|
||||
// Find mesh in the highest loaded LOD that is using the given material slot index and ray hits it
|
||||
bool result = false;
|
||||
float closest = MAX_float;
|
||||
Real closest = MAX_Real;
|
||||
Vector3 closestNormal = Vector3::Up;
|
||||
int32 closestEntry = -1;
|
||||
auto& meshes = model->LODs[model->HighestResidentLODIndex()].Meshes;
|
||||
@@ -498,7 +498,7 @@ bool StaticModel::IntersectsEntry(const Ray& ray, float& distance, Vector3& norm
|
||||
{
|
||||
// Test intersection with mesh and check if is closer than previous
|
||||
const auto& mesh = meshes[i];
|
||||
float dst;
|
||||
Real dst;
|
||||
Vector3 nrm;
|
||||
if (mesh.Intersects(ray, _world, dst, nrm) && dst < closest)
|
||||
{
|
||||
|
||||
@@ -191,11 +191,11 @@ public:
|
||||
// [ModelInstanceActor]
|
||||
bool HasContentLoaded() const override;
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
bool IntersectsItself(const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
bool IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal) override;
|
||||
bool IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex) override;
|
||||
bool IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal) override;
|
||||
bool IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user