2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-09-12 13:55:17 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Snapping/BasePositionSnapSolver3.h"
|
|
|
|
|
|
|
|
|
|
class FToolDataVisualizer;
|
|
|
|
|
|
2021-03-09 19:33:56 -04:00
|
|
|
namespace UE
|
|
|
|
|
{
|
|
|
|
|
namespace Geometry
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2019-09-12 13:55:17 -04:00
|
|
|
/**
|
|
|
|
|
* FRaySpatialSnapSolver solves for a Point snap location based on an input Ray
|
|
|
|
|
* and a set of snap targets (3D points and 3D lines).
|
|
|
|
|
*
|
|
|
|
|
* See FBasePositionSnapSolver3 for details on how to set up the snap problem
|
|
|
|
|
* and get results.
|
|
|
|
|
*/
|
|
|
|
|
class MODELINGCOMPONENTS_API FRaySpatialSnapSolver : public FBasePositionSnapSolver3
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FRaySpatialSnapSolver();
|
|
|
|
|
|
2019-11-11 16:57:36 -05:00
|
|
|
/**
|
|
|
|
|
* Optional function that will be used to project potential snap points onto constraints.
|
|
|
|
|
* Note that Line/Curve constraints are still respected, so eg if this projects to a 3D grid,
|
|
|
|
|
* then when calculating possible line-snap positions, the 3D grid point will be projected back
|
|
|
|
|
* onto the line targets.
|
|
|
|
|
*/
|
|
|
|
|
TFunction<FVector3d(const FVector3d&)> PointConstraintFunc = nullptr;
|
|
|
|
|
|
2019-09-12 13:55:17 -04:00
|
|
|
//
|
|
|
|
|
// solving
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/** Solve the snapping problem */
|
|
|
|
|
void UpdateSnappedPoint(const FRay3d& Ray);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Utility rendering
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/** Visualization of snap targets and result (if available) */
|
|
|
|
|
void Draw(FToolDataVisualizer* Renderer, float LineLength, TMap<int,FLinearColor>* ColorMap = nullptr);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
TArray<FSnapTargetPoint> GeneratedTargetPoints;
|
|
|
|
|
void GenerateTargetPoints(const FRay3d& Ray);
|
2021-03-09 19:33:56 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace UE::Geometry
|
|
|
|
|
} // end namespace UE
|