• 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 Monko · May 27, 2013 at 07:05 PM · lagmarching cubes

Marching Cubes algorithm acting slow

I have finally finished a working, functioning marching cubes algorithm. I have my character, and I can dig holes into the "terrain" of the marching cubes mesh. (simaler to minecraft). The problem is, each time I click the mouse to "dig", the game lags for up to 2 seconds. I went online and found other peoples videos using marching cubes, and they are adjusting the mesh rapidly without any lag.

For example: http://www.youtube.com/watch?v=qIGgUFP33fc

Does anyone who is experienced with meshes or marching cubes know any of reasons why adjusting a mesh causes so much lag? How did they do it in the video so quickly? My ultimate goal is to be able to edit the "terrain" in real time just like the video.

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

2 Replies

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

Answer by Bunnybomb7670 · May 27, 2013 at 10:13 PM

Firstly, you need to be splitting your mesh up into chunks, that video looks like its all one mesh, but it will be split into chunks so that the mesh updates will only occur on specific chunks. This chunk system is your vital goal towards creating a workable playable game. Another thing you must do is optimize your mesh code as much as possible, remove any un necessary code from the mesh update function because I can tell you this, it WILL slow your performance down a lot.

Chunks can be done easily, I did it in my Voxel Engine which I am working on, It is done through having a controller object that instantiates the area of chunks with empty data and then fills them with procedural data which is split along the chunks. It is quite a pain to do but it is well worth it for the performance gain you get.

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 Monko · May 28, 2013 at 02:19 AM 0
Share

Ok , I understand the idea of chunks. So ins$$anonymous$$d of creating one giant 100*100*100 cube, I will need to create many 10*10*10 cubes. The problem is, my code is running with 10*10*10, and its still super slow whenever I adjust the terrain. I will optimize any code possible for efficency, but Im still open to any suggestions, sample code, or websites from anyone.

avatar image Bunnybomb7670 · May 28, 2013 at 10:24 AM 0
Share

If you dont $$anonymous$$d, could you post your code on how your generating these " blocks " because I need to see how you are doing it, are you generating every single face of the blocks, or are you only generating outside faces? any samples of your generate and update code would be good because I can look through it and try find any issues with it.

avatar image
1

Answer by Monko · Jun 07, 2013 at 11:47 PM

OK, after 10 days, I finally figured out whats wrong. it simply involved optimizing my code for efficiency.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

14 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

Related Questions

2d game lagging 2 Answers

Multiplayer lagging in player but not in editor. 0 Answers

Animation.RebuildInternalState spike 3 Answers

Lag of video loading 1 Answer

Character Motor causes serious lag. 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