• 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
1
Question by Kiloblargh · Oct 18, 2012 at 04:23 PM · terrainmeshdynamiclocalfaster

Can I move just some of the verts on a mesh?

I would say "terrain," but I don't think I want to use Unity's built-in Terrains for this. What I am trying to avoid is setting every single vertex's position every single frame when there are only a handful of them that are actually being moved. I think being able to do this is make-or-break for the feasibility of a new game concept I'm kicking around.

I think I should have an array (dictionary) of vertex numbers vs world space x-z coords. Then another of vertex numbers vs an array of all the numbers of that vertex's closest neighbors. (Which is probably harder to calculate than it is to say.) Am I on the right track though?

The procedural examples all iterate through every vertex in a temporary array and then set the mesh's vertex positions (or colors) all at once. Is there some reason why you "have to" do it like that?

Comment
Add comment · Show 3
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 flaviusxvii · Oct 18, 2012 at 04:27 PM 0
Share

Are yous using this mesh for physics as well (ala $$anonymous$$eshCollider)?

avatar image Kiloblargh · Oct 18, 2012 at 04:35 PM 0
Share

I'm not using it for anything yet, it's just in my head. But I'm going to say no, I don't want there to be a mesh collider.

avatar image Fattie · Oct 18, 2012 at 04:36 PM 1
Share

of course you can ! go for it. are you already familiar with manipulating mesh in realtime ? if not expect a learning curve of a few months

as Eric pointed out recently - I can't find the damn question - it's critical to note that it is very slow to update a mesh collider, you can't do it in real time, so forget that if that's your plan.

(other alternatives for you could just be selecting from a random selection of 50 or whatever surfaces, depending on your game?)

may be relevant ..

http://answers.unity3d.com/questions/315059/how-to-improve-performance-while-generating-extrud.html

you mention vertex neighbors in passing .. note ...

http://answers.unity3d.com/questions/193695/in-unity-is-there-a-fast-way-to-find-nearby-triang.html

you mention "The procedural examples.." I find them all to be not very good really! heh! i'd kinda recommend just completely ignoring them

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Eric5h5 · Oct 18, 2012 at 04:45 PM

You must update every vertex in a mesh even if you only are changing a few. However, you don't need a temporary array. You can use a permanent Vector3 array for the vertices, and only change the relevant entries, but doing "mesh.vertices = myVertices" copies the entire array to the mesh, and is the only way of updating meshes.

Comment
Add comment · Show 2 · Share
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 Kiloblargh · Oct 18, 2012 at 05:06 PM 0
Share

Ok; that's what I was thinking. I guess I can test it myself, but is doing that every frame a big framerate hit and is "mesh.vertices = myVertices" expensive in direct proportion to the number of vertices being copied? (If so might just say "#$@*% it, I'm going voxels.")

avatar image Eric5h5 · Oct 18, 2012 at 09:34 PM 0
Share

is doing that every frame a big framerate hit

Depends on the size and number of the meshes, and how fast the hardware is.

is "mesh.vertices = myVertices" expensive in direct proportion to the number of vertices being copied?

Yes.

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

13 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

Related Questions

Can a dynamic mesh be made NOT readable? to save mem 1 Answer

Deform Terrain With Mesh 0 Answers

Having trouble getting a smooth collision with dynamic mesh collider 0 Answers

Editing Terrain Topology at Runtime 0 Answers

Spherical Terraing LOD 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges