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 ignotuscaligo · Jun 20, 2011 at 10:03 PM · meshdynamiccollide

Dynamic Mesh Collider - Optimization

So I've managed to create a mesh, alter its shape, and update its collision mesh every frame (right now its just a wave, but it works, it pushes cubes around).

My main thing now is that when the mesh gets too big, the updating slows down like crazy. The one line that slows the process is:

 //Defined at start
 private var meshCollide : MeshCollider; //later defined as the mesh collider 
                                         //on this object
 private var clearMesh : Mesh; //stays empty
 private var mainMesh : Mesh; //the mesh whose values I am adjusting

 //Called in a "Update Mesh" function I have (called on each Update)
 meshCollide.sharedMesh = clearMesh; //this line causes the delay, 
                                     //but allows the new mesh to be read properly
 
 meshCollide.sharedMesh = mainMesh;


Is there a more efficient way of doing this?

EDIT: Well that was quickly resolved. I found that by using smaller "chunk" objects rather than one big one, the updating speed dramatically increased. Less memory operations, I would guess.

Comment
Add comment · Show 2
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 · Jun 20, 2011 at 10:12 PM 1
Share

$$anonymous$$esh collision is just ridiculously expensive no matter which way you cut it. If you could approximate the wave action (or whatever future action you are planning) with complexes of convex colliders (boxes, spheres) it would be much easier for the physics engine to handle.

avatar image ignotuscaligo · Jun 20, 2011 at 10:17 PM 0
Share

What I'm thinking is using this system to allow something like an explosion to deform the terrain, so in execution, this change would only happen once during those events. One way I found to optimize this was ins$$anonymous$$d of using one large object and having to change its entire mesh all at once, im using smaller "chunks", so when parts of them need to update, its a significantly faster memory operation. i was running 9 objects that made up the same area as the slower, larger one, and it was running significantly faster (from 0.3fps to 20fps), and that was with all of them updating every frame. Updating just one at a time runs easily at 45-60fps, and still allows nice collision.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TomNCatz · Sep 29, 2011 at 03:58 AM

You could also try swapping

meshCollider.sharedMesh = clearMesh;

for

meshCollider.sharedMesh.Clear();

This may clear it more efficiently for you.

Comment
Add comment · 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

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

How to make a dynamic mesh visible in Scene View 1 Answer

Updating Dynamic Mesh's Collider is Too Slow 1 Answer

How to make a mesh adjust its form around specific points 1 Answer

Why does Mesh.CreateVBO spike every few seconds on iOS Metal 0 Answers

Generating Mesh at runtime, vertex count different 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