• 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 /
  • Help Room /
avatar image
0
Question by Soos621 · Nov 11, 2015 at 05:35 PM · unity 5mesh-deformation

Deforming mesh causes mesh tearing

Hello, i am attempting to create a deformable planet, which works when i first implemented the code but when i tried to optimize the code a bit it causes "tearing" in the mesh. Here is the code i am currently using (the commented out parts is older version which worked fine but was incredibly slow).

 public void DeformTris (List<int> tIndexes, float amountVertical){
     List<Vector3> vertecies = new List<Vector3> ();
     Vector3[] tempMesh = currentMesh.mesh.vertices;
     int[] triangles = currentMesh.mesh.triangles;
     foreach (int ti in tIndexes) {
         //vertecies.Add (tempMesh [triangles [ti * 3]]);
         //vertecies.Add (tempMesh [triangles [ti * 3 + 1]]);
         //vertecies.Add (tempMesh [triangles [ti * 3 + 2]]);
         Vector3 vert1 = tempMesh[triangles[ti * 3]];
         Vector3 directionToCenter = this.transform.position - vert1;
         Vector3 newPosition = vert1 + directionToCenter.normalized * amountVertical;
         tempMesh[triangles[ti * 3]] = newPosition;
         Vector3 vert2 = tempMesh[triangles[ti * 3 + 1]];
         Vector3 directionToCenter2 = this.transform.position - vert2;
         Vector3 newPosition2 = vert2 + directionToCenter2.normalized * amountVertical;
         tempMesh[triangles[ti * 3 + 1]] = newPosition2;
         Vector3 vert3 = tempMesh[triangles[ti * 3 + 2]];
         Vector3 directionToCenter3 = this.transform.position - vert3;
         Vector3 newPosition3 = vert3 + directionToCenter3.normalized * amountVertical;
         tempMesh[triangles[ti * 3 + 2]] = newPosition3;
     }

     /*for (int vertex = 0; vertex < tempMesh.Length; vertex++) {
         if (vertecies.Contains(tempMesh [vertex])) {
             Vector3 directionToCenter = this.transform.position - tempMesh [vertex];
             Vector3 newPosition = tempMesh [vertex] + directionToCenter.normalized * amountVertical;
             tempMesh [vertex] = newPosition;
             //break;
         }
     }*/
     currentMesh.mesh.vertices = tempMesh;
 }

My idea was that i already had the triangle index(s) from a raycast and so i could manipulate the vertices of the triangle without iterating through the few thousand vertices of the entire mesh. This has cause a problem in the mesh (shown in the picture below) and I'm not quite sure if there is a way that i am able to solve it without splitting the planet up into multiple objects, which causes a bunch of problems anyway. If anyone could help me at least identify why this "tearing" or splitting of the mesh is happening it would be most appreciated, thanks and have a great day.

alt text

mesh-tearing.png (363.3 kB)
Comment
Add comment · Show 1
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
avatar image Soos621 · Nov 18, 2015 at 08:10 PM 0
Share

I still have not solved this problem is anyone could help me understand why directly manipulating the mesh triangle vertices like this results in $$anonymous$$ring of the mesh, thanks again ^.^

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

40 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What do I need to know to do this? 1 Answer

how to create multiple levels for my bubble shooter game? 0 Answers

How to move the camera in VR mode? 2 Answers

Unet: Bullets only spawn only spawn on host, visible only on host 0 Answers

My Enemies walk through objects and my FPS character model 3 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