Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by mavasher · Nov 27, 2013 at 10:47 PM · colliderperformance optimizationprocedural mesh

Performance Question: 1 big vs many small mesh colliders

I am procedurally generating a tubular structure. The radius/shape varies over the length of the tubular structure. For my purposes I need accurate physics on that shape. As the tube is constructed by connecting ring A of vertices with ring B of vertices with ring C of vertices etc, etc, I want to know what would be better performance-wise. Should I make the entire tubular structure one mesh for colliders or should I break each ring-to-ring segment into a separate child collider mesh of the parent visible geometry?

Essentially, is it better to have one large multi-segment tubular mesh collider or should I break each segment of the tubular structure into a different mesh collider.

I know that mesh colliders are more expensive. If there were a good way to do this with just spheres I would do that, but I really need as close to precise result as I can get for this application.

Comment
Add comment · Show 6
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 OP_toss · Nov 28, 2013 at 12:46 AM 0
Share

Pretty sure size of colliders doesn't really matter. So 1 single collider would always be better. The lower resolution the mesh collider, the better, obviously. Try to avoid many vertices near one another, complex bevels and extrusions, very thin enclosed meshes, etc.

Too bad capsules don't have an option for flat tops...

avatar image mavasher · Nov 29, 2013 at 02:28 AM 0
Share

Thanks for the response. It's not really the size of the collider that's the question. It's the number of triangles in the mesh collider. Is it better to have one large mesh collider with many triangles or multiple mesh colliders with fewer triangles?

I've also thought of child capsules but again they don't approximate the shape well enough for the application. It's one of those rare situations where I really need the collider to be very accurate.

avatar image OP_toss · Dec 02, 2013 at 06:32 PM 0
Share

Hmmm, tough call, I would think that splitting it up where it logically makes sense might improve performance by allowing for culling to take place. So if one collider is off frame, while another is on frame, there's less to process, potentially. As long as your splitting doesn't add geometry I'd say splitting is better. But this may be worth profiling to be sure, if performance is key and this is a huge part of your performance.

I'd be curious to know the result of such a test, so please post again with results if you end up testing this out!

avatar image axCed · Dec 02, 2013 at 06:45 PM 0
Share

Considering that it is a procedurally generated mesh, I suggest you to use the mesh collider.

Now, about 1 big vs many small, you should use one big. Use many small if you need to do something particular with each segment (exploding for example, but I don't feel you're planning to do that).

About performance, I think the less gameObjects/component you have, the less Unity resources/performance you're using.

I see you're new in the Unity community. Welcome. When someone answer your questions, you should vote and check the good answer.

avatar image mavasher axCed · Dec 02, 2013 at 11:29 PM 0
Share

Thanks for the answer. You are right that I don't plan on doing anything with the individual segments. I also think that more objects is more of a problem than one more complex object, but I don't know which is why I asked the question. It seems like I've getting conflicting answers from people; which is fine. $$anonymous$$ostly I wanted to know if it was clearly one option or the other and so I didn't do something inherently wrong.

I am going to go ahead and write two versions of the same program: one that uses one large mesh as you say and one that breaks the mesh into smaller segments. The total triangles should be the same. I won't have time just now to write the different versions but I'll post my results when the experiment is done.

avatar image mavasher · Dec 02, 2013 at 11:32 PM 0
Share

Thanks for the comments. I plan on writing the two options into code and then testing it out. I'll post the results here.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by camander321 · May 10, 2015 at 03:43 PM

I'm sure you've solved this, and I'm not sure how this would scale to your project, but if performance is a concern, this is what I would do.

Create an invisible mesh that copies just the vertices closest to whatever object will be colliding with the tube. I can't imagine this would be too hard, provided that the distance between rings is known and each ring has the same number of vertices. This will give you accurate collisions, but only worry about relevant vertices

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
avatar image
0

Answer by Sisso · Dec 02, 2013 at 07:02 PM

Personally I think that you must split in objects of avarage size. I don't know how unity3d engine works. But exists many types of otimizations used by physic engines to exclude a object from collision test that didn't apply for large or concave objects.

For example, you can have a AABB (http://en.wikipedia.org/wiki/Bounding_volume) for each game object and put into a octree (http://en.wikipedia.org/wiki/Octree), only objects in the same octree node that collide your AABB you must check for mesh colision. For a large mesh, the AABB will always have contact and you must always check for mesh collision.

But in the end, it is better make what is easy for you and test for perfomance.

Comment
Add comment · Show 1 · 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 Kobix · Feb 02, 2014 at 01:08 PM 0
Share

To me it is also more logically to split mesh into more smaller pieces because of bounding box optimisation.

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

20 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

Related Questions

Large number static colliders performance impact in a scene? 1 Answer

How do I add a MeshCollider to my randomly generated island through Code 2 Answers

Sticking object on mesh 0 Answers

add mesh to trail renderer and MAKE IT SOLID !! 1 Answer

Internal collisions 1 Answer


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