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 PandrPi · Feb 01, 2018 at 09:25 AM · meshgenerationthreadsprecisionfloatingpoint

Starting mesh generation thread before changing chunk transform position

Hello, I had a "nice" meeting with float precision limitation, and I found an easy solution. If player position on x, y or z axis is bigger than 10,000 units then subtract 10,000 units from player pos and position of every chunk of world. It works good. I use thread independent from main to generate vertices' heights array and than in coroutine I attach generated array to mesh. I use threading not to freeze the game, because ganerating can take about one second, but time is not my problem. The problem occurs when the distance between player and some chunk is enough to generate it, but a little time later player position on some axis is bigger 10,000 so i had to change chunk pos to new, displaced position, but generating thread have an old chunk position and as a result generated mesh is displaced and don't match the actual chunk position. I hope you understood what I wanted to say. I also hope that you have some ideas to solve this. Thanks in advance.

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

1 Reply

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

Answer by victorbisaev · Feb 01, 2018 at 10:08 PM

One of the possible solutions is to "revert" the Universe - don't move player, move the world around.

So your player is always at (0,0,0) and when he/she moves in some direction, the world moves in opposite direction instead.

Generation of each chunk happens on the edges of the world (say, 5000 units away) so much earlier than the player reaches any of the border, and a chunk(s) which goes out of 5000 limit just been destroyed. Imagine your player in the middle of 10000x100000 terrain, and chunks of the terrain appear/disappear at the outer edges of the terrain when the player move in some direction so the terrain around the player is always of the same size.

The approach described above allows to create really "infinite" worlds to explore.

And for your case with displacement I would suggest to save the value of the displacement when the generation thread started generation and when generation is done check that current value of the displacement matches the saved value. If "yes", then continue, if "no" then re-generate the same chunk with the new displacement value.

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 PandrPi · Feb 01, 2018 at 10:17 PM 0
Share

Thank you very muck, I had a familiar idea, but I decided that it would be better to wait for other opinion. So I'll try to do it such a way you said, hope this would help. Thank you again :)

avatar image victorbisaev PandrPi · Feb 01, 2018 at 10:40 PM 0
Share

Yes, that is good idea to use floats only with values around 0. Then the results are correct and reliable. Good luck with your task!

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

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

Related Questions

How to set up UV for lightmaps for generated meshes? 4 Answers

Im making a mesh for a planet, but this happens... 0 Answers

Unity networking using cells 0 Answers

Generated mesh loses lighting at certain angles 2 Answers

Procedurally Generated Cube Mesh 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