Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by crushingcups · Oct 19, 2015 at 11:46 PM · meshvector3vertexedgeedges

How can I find the terminal edges on a mesh, after removing triangles from it?

Hi guys, I'm trying to implement a convex hull algorithm. I am able to remove all the faces from a mesh, that the point to be added "sees", but I'm having trouble finding the position of the remaining edges after deletion. I'd like to generate triangles from the edges around the hole and the point I need to add to the hull. Here are the 2 relevant functions I have:

 private List<int> FindFacesUnderPoint(ref Mesh currentMesh, Vector3 currentPoint, ref List<Vector3> points)
         {
             List<int> trianglesToDelete = new List<int>();
             for (int i = 0; i < currentMesh.triangles.Length; i += 3)
             {
                 Vector3 normal = currentMesh.normals[i];
                 Vector3 pointToVert = currentPoint - currentMesh.vertices[i];
                 float product = Vector3.Dot(pointToVert, normal);
     
                 if (product > 0)
                 {
                     trianglesToDelete.Add(i);
                     trianglesToDelete.Add(i+1);
                     trianglesToDelete.Add(i+2);
     
                     points.Add(currentMesh.vertices[i]);
                     points.Add(currentMesh.vertices[i+1]);
                     points.Add(currentMesh.vertices[i+2]);
                 }
             }
             points = points.Distinct().ToList(); // remove duplicates
             return trianglesToDelete;
         }

Here I return the indices of the triangles I want to delete (which works, see function below), and write to my "points" list, the positions of the extremities of each edge, that I will then take in clockwise order from the point I want to add to the hull, so my triangles wind properly.

  private void DeleteTriangles(ref Mesh currentMesh, List<int> tris)
         {
             var t = currentMesh.triangles;
             for (int i = 0; i < tris.Count; i += 3)
             {
                 t[tris[i]] = 0;
                 t[tris[i+1]] = 0;
                 t[tris[i+2]] = 0;
             }
             currentMesh.triangles = t;
         }

The DeleteTriangles function deletes the correct triangles, but when I feed my "points" list from FindFacesUnderPoint to my Patch function (that I left out for brevity) from all points in front of it, not just the ones where edges have been removed. How can I get these points?

Here is a gif I made that illustrates the problem: when the point circled in blue gets added to the hull, the edge I marked in yellow gets split up into 2 because also this middle point is "in front of" the one circled in blue. I've thought of computing a 2D convex hull to only take convex ones from this list, but there must be an easier way. Any help would be greatly appreciated.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

instantiate object and align with object surface 2 Answers

What is the order/connection of array elements in mesh.vertices? 2 Answers

How to remove white blinking edge on mesh? 1 Answer

Creating a mesh for an overview map 0 Answers

Using compute shader, how to take every vertex of a mesh and make a cube spawn and move to each one? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges