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 toothycat · Jun 30, 2011 at 11:50 AM · framerategarbage-collectionskinningspikes

SkinnedMeshRenderer.bones heap churn

So, I'm doing my own skinning on a few vertices from my mesh, to obtain accurate animated centre / bounds information.

I notice that a garbage collection gets triggered every 2-3 seconds, taking 7-8ms, which is a rather large spike; according to the profiler, the only source of memory allocations is SkinnedMeshRenderer.get_bones(), called from the SkinnedMeshRenderer's bones property from my skinning code. Presumably the property's accessor is taking a copy of the bones array and returning that to me (why?)

Is there a way of transforming a point by a bone that does not cause the bone to get copied under the hood?

My skinning code is trivial, but here's the relevant bit (appears in the profiler callstack as the immediate caller of SkinnedMeshRenderer.get_bones()), just in case someone spots I'm accessing things in some particularly bad way:

 Vector3 pos = m_renderer.bones[m_verts[i].m_weights.boneIndex0].TransformPoint(m_verts[i].m_pos0) * m_verts[i].m_weights.weight0
             + m_renderer.bones[m_verts[i].m_weights.boneIndex1].TransformPoint(m_verts[i].m_pos1) * m_verts[i].m_weights.weight1
             + m_renderer.bones[m_verts[i].m_weights.boneIndex2].TransformPoint(m_verts[i].m_pos2) * m_verts[i].m_weights.weight2
             + m_renderer.bones[m_verts[i].m_weights.boneIndex3].TransformPoint(m_verts[i].m_pos3) * m_verts[i].m_weights.weight3;


EDIT: factoring out the access to the bones property does indeed massively reduce heap churn; yet doing that is rather counterintuitive, and the transform array still gets copied once a frame without any obvious need, so the question of how to skin a set of verts without hitting the heap at all still stands.

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Garbage Collection (StackTraceUtility) - Profiler Spikes 1 Answer

large sudden profiler spike 0 Answers

Why v-sync show in profiler while is off? 0 Answers

What causes an increase in editor GUI garbage collection? 2 Answers

Android device LG G3 Frame rate problem 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