Search Feedback

84
votes

Efficient method for closest point on mesh lookup

Scripting

-

-

It would be extremely useful if we could get a function which would return the closest point on a mesh including barycentric coordinates.

Right now this can sort of be hacked up using the mesh collider variant, but it is far less than ideal.

The ideal method prototype would return a struct containing;
- Triangle index
- Point on mesh
- Barycentric coordinates between triangle(N+0, N+1, N+2)
- Bonus points for additional returns (e.g. blended normal, UVs, etc)

Comments (1)

  1. 436235f50ac4866e3e58bcbce1507663?d=mm

    AFrisby

    May 16, 2017 09:13

    Since I hit submit before re-reading my entry; this is the closest point on a Mesh class; using a Vector3 for the closest point (in local mesh coordinates).

    e.g.

    Mesh mesh;
    mesh.ClosestPoint(Vector3 searchTarget);

    Right now this can be done in pure C# just fine - but even with optimisation (e.g. KDTrees, etc) it can be fairly slow. This kind of pure-math function should be in C/C++ at the engine level.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(9242)

2D

(233)

Ads

(42)

AI & Navigation

(70)

Analytics

(103)

Animation

(318)

Asset Store

(234)

Assets

(493)

Audio

(158)

Cloud Build

(98)

Collaborate

(33)

Docs & Tutorials

(202)

Editor

(2137)

Everyplay

(13)

Game Performance Reporting

(15)

General

(825)

Graphics

(783)

GUI

(371)

Input

(147)

Licensing

(76)

Networking

(163)

Physics

(346)

Platforms

(407)

Profiling & Optimization

(71)

Runtime

(164)

Scripting

(1030)

Terrain

(151)

WebGL

(132)