Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Creating a GeometryModel3D requires a MeshGeometry3D and a Material.

For example,

GeometryModel3D myGeometryModel3D = new GeometryModel3D(myMeshGeometry3D, new DiffuseMaterial(Brushes.Green));


The models I am dealing with can have hundreds or thousands of GeometryModel3D objects. Will it have a performance benefit if I use a single instance of DiffuseMaterial for many GeometryModel3D instances instead of creating a new one for every GeometryModel3D instance?

What I have tried:

GeometryModel3D myGeometryModel3D = new GeometryModel3D(myMeshGeometry3D, new DiffuseMaterial(Brushes.Green))
Posted
Comments
Graeme_Grant 16-Mar-17 22:17pm    
Have you set up a simple test and tried it?
HD86_ 17-Mar-17 11:30am    
No, because I don't know how to detect the difference. I'd like a theoretical answer and not only a practical one. Does creating more brush instances occupy more memory than assigning a single brush to many GeometryModel3D objects?
HD86_ 17-Mar-17 12:38pm    
I made the following test: I built several GeometryModel3D objects with the same material. Then I changed the material for one of them and that changed the material for all the other objects that share the same material. Next I built GeometryModel3D objects each with its own material. I changed the material for one object, but the others were not affected. Conclusion: if I use one material instance for each GeometryModel3D instance, that will occupy more memory.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900