25 mOrigin({ 0.0f, 0.0f, 0.0f, 1.0f }),
46 if (tmin == -std::numeric_limits<float>::max())
48 LogAssert(tmax == std::numeric_limits<float>::max(),
"Invalid inputs.");
52 LogAssert(tmin == 0.0
f && tmax > 0.0
f,
"Invalid inputs.");
70 float closest = iter->distanceToLinePoint;
71 for (; iter !=
end; ++iter)
73 float tmp = iter->distanceToLinePoint;
94 float closest = std::numeric_limits<float>::max();
95 for (; iter !=
end; ++iter)
99 closest = iter->distanceToLinePoint;
107 for (++iter; iter !=
end; ++iter)
109 if (iter->t >= 0.0f && iter->distanceToLinePoint < closest)
111 closest = iter->distanceToLinePoint;
135 float closest = std::numeric_limits<float>::max();
136 for (; iter !=
end; ++iter)
140 closest = iter->distanceToLinePoint;
148 for (++iter; iter !=
end; ++iter)
150 if (iter->t <= 0.0f && closest < iter->distanceToLinePoint)
152 closest = iter->distanceToLinePoint;
172 auto visual = std::dynamic_pointer_cast<
Visual>(
object);
178 Matrix4x4<float> const& invWorldMatrix = visual->worldTransform.GetHInverse();
181 #if defined (GTE_USE_MAT_VEC) 182 temp = invWorldMatrix *
mOrigin;
183 line.
origin = { temp[0], temp[1], temp[2] };
185 line.
direction = { temp[0], temp[1], temp[2] };
187 temp = mOrigin * invWorldMatrix;
188 line.
origin = { temp[0], temp[1], temp[2] };
189 temp = mDirection * invWorldMatrix;
190 line.
direction = { temp[0], temp[1], temp[2] };
197 VertexBuffer* vbuffer = visual->GetVertexBuffer().get();
198 std::set<DFType> required;
210 IndexBuffer* ibuffer = visual->GetIndexBuffer().get();
218 PickSegments(visual, positions, vstride, ibuffer, line);
222 PickPoints(visual, positions, vstride, ibuffer, line);
228 auto node = std::dynamic_pointer_cast<
Node>(
object);
234 for (
int i = 0; i < numChildren; ++i)
236 std::shared_ptr<Spatial> child = node->GetChild(i);
259 for (
unsigned int i = 0; i < numTriangles; ++i)
307 #if defined (GTE_USE_MAT_VEC) 371 record.
t =
result.parameter[0];
374 record.
bary[2] = 0.0f;
378 #if defined (GTE_USE_MAT_VEC) 403 for (
unsigned int i = 0; i < numPoints; ++i)
431 record.
t =
result.lineParameter;
432 record.
bary[0] = 1.0f;
433 record.
bary[1] = 0.0f;
434 record.
bary[2] = 0.0f;
438 #if defined (GTE_USE_MAT_VEC)
void operator()(std::shared_ptr< Spatial > const &scene, Vector4< float > const &origin, Vector4< float > const &direction, float tmin, float tmax)
#define LogAssert(condition, message)
int GetNumChildren() const
uint32_t GetNumPrimitives() const
#define LogInformation(message)
bool GetSegment(uint32_t i, uint32_t &v0, uint32_t &v1) const
Vector< N, Real > direction
float distanceToPrimitivePoint
void PickSegments(std::shared_ptr< Visual > const &visual, char const *positions, unsigned int vstride, IndexBuffer *ibuffer, Line3< float > const &line)
float GetMaxDistance() const
unsigned int GetElementSize() const
GVector< Real > HLift(GVector< Real > const &v, Real last)
static PickRecord const msInvalid
PickRecord const & GetClosestToZero() const
GLfixed GLfixed GLint GLint GLfixed GLfixed GLint vstride
void PickPoints(std::shared_ptr< Visual > const &visual, char const *positions, unsigned int vstride, IndexBuffer *ibuffer, Line3< float > const &line)
Vector4< float > primitivePoint
std::vector< PickRecord > records
#define LogWarning(message)
IPType GetPrimitiveType() const
Real Normalize(GVector< Real > &v, bool robust=false)
bool GetPoint(uint32_t i, uint32_t &v) const
void SetMaxDistance(float maxDistance)
std::shared_ptr< Visual > visual
DualQuaternion< Real > Length(DualQuaternion< Real > const &d, bool robust=false)
void PickTriangles(std::shared_ptr< Visual > const &visual, char const *positions, unsigned int vstride, IndexBuffer *ibuffer, Line3< float > const &line)
GLfloat GLfloat GLfloat v2
GLsizei GLsizei numSegments
float distanceBetweenLinePrimitive
PickRecord const & GetClosestNonnegative() const
Vector4< float > linePoint
bool GetTriangle(uint32_t i, uint32_t &v0, uint32_t &v1, uint32_t &v2) const
void ExecuteRecursive(std::shared_ptr< Spatial > const &object)
PickRecord const & GetClosestNonpositive() const
float distanceToLinePoint
Vector4< float > mDirection
char * GetChannel(VASemantic semantic, unsigned int unit, std::set< DFType > const &requiredTypes)