Notifications
Clear all

[Closed] Undocumented trimesh properties

I noticed that by accesing directly the mesh value of geometry I can achieve things faster and easier. For example:

m=myMesh.mesh
for v in m.verts do
(
    p=v.pos
    ...
)

In the for loop I have an easier acces to the verts as using getVert, and I don´t even have to care about node transformation. If tallking about transormation there some other very useful posibilities like this:

m=myMesh.mesh
move m [x, y, z]
rotate m rot
myMesh.mesh

This alows me to manipulate only mesh transformation without the one from the node.
Wondering if there is some other such really usefull things I can perfor on a trimesh? Unfortunatelly nothing from this stuff is mentioned in the documentation.

wondering if it´s posible to iterate the faces same way as verts?

6 Replies

Sorry, what I was meaning is something like this

m = $.mesh
for f in m.faces do
(
...
)

so without using geter or seter fns. I know how to get faces with the getFace fn.

Okay, but why do you need that? As far as I know there’s no performance differences between for v in m.verts do and for vi in 1 to m.numVerts do. Both functions work with triMesh, so you don’t have to bother the node transformation.

Posibly I understood something wrong, but have heared somewhere that for v in m.verts do should be faster then for vi in 1 to m.numVerts do. Also a geter fn, as far I know, is a bit slower then direkt access, but my knowledge about that thing is very low, so can be complete wrong.

1 Reply
(@polytools3d)
Joined: 10 months ago

Posts: 0

Whenever you hear such statements it is a good practice to try it by yourself.

Sometimes, performance varies depending on the situation, including OS, Max version, the whole code and the scene in question.

For instance, I could say that BitArrays are much faster than Arrays, and while that may be true in most situations, it can’t be taken as a general statement as in many cases Bitarrays will be much slower than Arrays.

In your case, if you take the time to write a little test script, you’ll find that what you heard don’t hold true in these examples.

(
	delete objects
	gc()
	
	obj = converttomesh (geosphere radius:50 segs:256)

	st=timestamp(); sh=heapfree
	for j = 1 to obj.numverts collect getvert obj j
	format "obj.numverts\n"
	format "\ttime:% heap:%\n" (timestamp()-st) (sh-heapfree)
	
	st=timestamp(); sh=heapfree
	for j in obj.verts collect j.pos
	format "obj.verts\n"
	format "\ttime:% heap:%\n" (timestamp()-st) (sh-heapfree)
	
	tmesh = snapshotasmesh obj
	
	st=timestamp(); sh=heapfree
	for j = 1 to tmesh.numverts collect getvert tmesh j
	format "trimesh.numverts\n"
	format "\ttime:% heap:%\n" (timestamp()-st) (sh-heapfree)
	
	st=timestamp(); sh=heapfree
	for j in tmesh.verts collect j.pos
	format "trimesh.verts\n"
	format "\ttime:% heap:%\n" (timestamp()-st) (sh-heapfree)
)

obj.numverts
time:215 heap:25640504L
obj.verts
time:252 heap:64000680L
trimesh.numverts
time:129 heap:25600384L
trimesh.verts
time:148 heap:64009704L

So I was wrong, thanks for explanation.