Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is managed data still needed?

See original GitHub issue

@keenanwoodall Since latest versions of Unity support Mesh.SetVertices, Mesh.SetNormals, etc with native arrays I was wondering if we still need to do this step?

From MeshData.cs:

// Copy the native data into the managed data for efficient transfer into the actual mesh.
DataUtils.CopyNativeDataToManagedData(dynamicManaged, DynamicNative, dataFlags);

I have tried bypassing it and doing this instead and it works fine, I think it might be more efficient since we can skip the managed overhead entirely?

if ((dataFlags & DataFlags.Vertices) != 0)
			if ((dataFlags & DataFlags.Normals) != 0)
			if ((dataFlags & DataFlags.Tangents) != 0)
			if ((dataFlags & DataFlags.UVs) != 0)
			if ((dataFlags & DataFlags.Colors) != 0)

If not then there is separate optimization I’d like to propose/implement that will be faster than MemCpy (see bottom of this page if curious: where CopyFromFast and CopyToFast is discussed)

Just want to get some thoughts on this in case I’m missing something, otherwise I’m thinking about stripping out the managed data stuff and submitting a pull request!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

keenanwoodallcommented, Aug 23, 2020

Preprocessor stuff has been added so it uses managed data before 2019.3 I made a test fbx with submeshes to see how it breaks and realized it wasn’t going to break because no deformer (that I’ve made) marks the triangles as changed in the data flags so it never gets copied.

I removed the data flags check so it always copies the triangles and the result was the first material being applied to the entire mesh since it was treated as one submesh. Was that how it broke for you, or did it do something else? Did you have a custom deformer that was modifying the triangles? I’m curious what caused the break.

I tried changing the code that sets the indices to this

if ((dataFlags & DataFlags.Triangles) != 0)
	for (int i = 0; i < to.subMeshCount; i++)
		var submesh = to.GetSubMesh(i);
			indices: 		from.IndexBuffer,
			indicesStart: 		submesh.indexStart, 
			indicesLength:		submesh.indexCount, 
			topology: 		submesh.topology, 
			submesh: 		i, 
			calculateBounds: 	false, 
			baseVertex: 		submesh.baseVertex

it’s on develop and it seems to work as well 👍

keenanwoodallcommented, Aug 21, 2020

Yea when I originally wrote this you couldn’t copy directly to the mesh from native collections. I’m glad the mesh API finally caught up! I just pushed the changes to develop. I think it should be stable, but like with other stuff I’ll sit on it a bit longer before merging.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Do You Need a Managed Database?
But let's assume you do have the freedom to move your database to the cloud. Don't forget that someone is still going to...
Read more >
Do we still need a data warehouse?
Yes, learning data warehousing is still relevant today because of its capability to integrate data, it is easy to use and because thousands...
Read more >
What Is Data Management and Why Is It Important?
Effective data management is a crucial piece of deploying the IT systems that run business applications and provide analytical information to help drive ......
Read more >
The data-driven enterprise of 2025
Though the proliferation of data is driven by unstructured or semi-structured data, most usable data is still organized in a structured ...
Read more >
Understanding Managed Databases
A managed database service can ease the stress of deploying and maintaining a database, but there are still a few things to keep...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found