[Closed] Two skinOps.ReplaceVertexWeights in a row ?
Hi all,
Is someone could tell me why I cant have two ReplaceVertexWeights one after the other ?
like such :
–1
skinOps.ReplaceVertexWeights MyObject.modifiers[#skin] vert BoneArray WeightArray
–2
skinOps.ReplaceVertexWeights MyObject.modifiers[#skin] vert BoneArray2 WeightArray2
Both work correctly when separate (or if I put one in comment) but I need them to be one after the other to do the operation on the same vert, in the same loop but on different bones.
Put like this the first Replace just get ignored, of course I have no errors and I have check the arrays are still correctly build.
Any ideas ?
Thanks
Blob
Understood what was wrong but then I am back to another problem I wanted to avoid :
For vert = 1 to AllVerts do
(
–Empty Arrays
BoneArray = #()
WeightArray = #()
BoneArray2 = #()
WeightArray2 = #()
– Get number of bones per verts
MyBonesPerVert = skinOps.GetVertexWeightCount MyObject.modifiers[#skin] vert
for Mybone = 1 to MyBonesPerVert do
(
-- get bones index and weights
BoneIndex = skinOps.GetVertexWeightBoneID MyObject.modifiers[#skin] vert Mybone
BoneWeight = skinOps.GetVertexWeight MyObject.modifiers[#skin] vert Mybone
--iif this bone index is == to the stored MySelectedFromBoneIndex then swap
if BoneIndex == MySelectedFromBoneIndex do
(
BoneIndex = MySelectedToBoneIndex
)
Append BoneArray BoneIndex
Append WeightArray BoneWeight
)
--1 Swap Bones
skinOps.ReplaceVertexWeights MyObject.modifiers[#skin] vert BoneArray WeightArray
--///////2ND LOOP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for Mybone = 1 to MyBonesPerVert do
(
-- get bones index and weights
BoneIndex2 = skinOps.GetVertexWeightBoneID MyObject.modifiers[#skin] vert Mybone
BoneWeight2 = skinOps.GetVertexWeight MyObject.modifiers[#skin] vert Mybone
--iif this bone index is == to the stored MySelectedFromBoneIndex then swap
if BoneIndex2 == MySelectedFromBoneIndex2 do
(
BoneIndex2 = MySelectedToBoneIndex2
)
Append BoneArray2 BoneIndex2
Append WeightArray2 BoneWeight2
)
--2 Swap Bones
skinOps.ReplaceVertexWeights MyObject.modifiers[#skin] vert BoneArray2 WeightArray2
)
As you can see I have two loops one after the other. Both are almost identical, if I put one in comment the other one left will works. Both together they just empty all my weights and I simply can’t figure out why. Is anyone have an idea ?
Thank you !
Blob
where do MySelectedFromBoneIndex, MySelectedFromBoneIndex2 & MySelectedToBoneIndex & MySelectedToBoneIndex2 initally get defined?
In the struct above. But no problem in this area. As I was saying, individually each loop is working fine, the swapping occurs with no problems at all. The issue comes when I want to do a second loop after the first.
There is something that makes the two loops interfering each others and I cannot see what.
Thanks
Blob