Thanks Jeremie,
I was referencing your code when I ran into the slowness to see if we
are doing anything different and we aren't really.
As a test I'm grabbing the XSI Man Armored and selecting the body mesh
and doing a local subdiv refinement with a setting of 2 then freezing
modeling. Then running the following code with the body mesh selected:
# Python
# =============================================
from platform import system as OStype
from time import clock
xsi = Application
log = xsi.LogMessage
sel = xsi.Selection
start_time = clock()
weights = [list(x) for x in sel(0).Envelopes(0).Weights.Array]
timeTaken = clock() - start_time
units = ["seconds" if OStype() is "Windows" else "milliseconds"][0]
msg = "It took "+str(timeTaken)+" "+units+" to process your code."
log(msg)
# =============================================
It's taking around 6 seconds for me.
Eric Thivierge
===============
Character TD / RnD
Hybride Technologies
On 30/05/2013 4:05 PM, Jeremie Passerin wrote:
Writting to the envelope array is usually pretty fast for me... what's
taking time (in my case) is doing all the normalization of values...
This is how I read my weights :
def getWeights(envelopeOp):
weightsTuple = envelopeOp.Weights.Array
return [weightsTuple[j][i] for i in range(len(weightsTuple[0])) for j
in range(len(weightsTuple))]
This is an example of how I set the weights (average weights) :
def averageWeights(envelopeOp, points=None):
'''
\remarksset the weights of given points to the average weights of
given points
\paramenvelopeOp Envelope Operator - the envelope operator.
\parampoints List of Integer - Index of vertices to average.
'''
deformerCount = envelopeOp.Deformers.Count
weightsTuple = envelopeOp.Weights.Array
weights = getWeights(envelopeOp)
if points is None:
points = range(mesh.ActivePrimitive.Geometry.Points.Count)
a = [0] * deformerCount
for pointIndex in points:
for def_index in range(deformerCount):
a[def_index] += weightsTuple[def_index][pointIndex]
for pointIndex in points:
for def_index in range(deformerCount):
weights[pointIndex*deformerCount + def_index] = a[def_index]/len(points)
envelopeOp.Weights.Array = weights
On 30 May 2013 12:58, Eric Thivierge <ethivie...@hybride.com
<mailto:ethivie...@hybride.com>> wrote:
Anyone know if there is a way to speed up reading and writing
speeds to the Weights Array for envelopes? It's extremely slow on
high point count / high deformer count meshes.
I'm using Python but I'm not sure if that is the reason for the
slowness. Anyone else already do some testing or have any findings
that may help?
I'm writing some common tools that many have already done such as
normalizing weights, pruning, symmetrizing, etc.
Any experiences confirming this slowness or experiences where it
is exponentially faster in other languages are welcome too.
Thanks,
--
Eric Thivierge
===============
Character TD / RnD
Hybride Technologies