My advice is to do the deformation and the push operation on a temporary array 
first for performance reasons, this will reduce the amount of the data copying 
in and out from the mesh which is slow. The only downside is probably the fact 
that you will need to re-calculate the post deformation normals yourself before 
applying the push.


From: softimage-boun...@listproc.autodesk.com 
[mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Matt Lind
Sent: Saturday, April 26, 2014 9:56 AM
To: Hsiao Ming Chia; softimage@listproc.autodesk.com
Subject: RE: SDK: port groups in custom operators

Is there any advantage to using port groups (other than accounting for 
arbitrary dynamic connections)?

I think it's time the Softimage wiki got integrated into the standard 
documentation that ships with the product.  Since there is no more development, 
there's no point in having information scattered in several places around the 
internet.


Another issue:

I am writing a custom operator (deformer) in C++ which is experiencing an 
update issue.  It takes several inputs, and has a single output.  The deformed 
mesh has both an input and output port with the output port defined first.  I 
can read and write the point positions of the deformed mesh producing desired 
results - except for one detail.

One feature of my deformer is to allow the user to 'push' the points along the 
geometry's normal using a weight map just like the native push deformer.  
However, the nature of my operator requires the point positions be written to 
the output port to update the deformed mesh before I can perform the push 
calculations as I need updated normals to do that.  The problem I am 
experiencing is the 2nd attempt to write the point positions during the 
_Update() callback do not update the point positions.  The weird part is I had 
the double update working for the push in previous versions of my plugin, but 
the geometry updates were one cycle behind.  Fixing the one cycle lag (caused 
by storing primitives in plugin userdata) broke the push map feature.  2nd 
attempt to write to the output port results in nothing happening.

So....how can I deform a mesh, then perform a push on it after it's been 
deformed?  Do I have to compute the normals myself?


Pseudo code:

//-----------------------------------------
                Primitive oPrimitive = oCustomOperator.GetInputValue( 
portInputDeformedMesh );
                MATH::CVector3Array aPointPositions = 
oPrimitive.GetGeometry().GetPoints().GetPositionArray();

                for ( LONG I = 0; I < aPointPositions.GetCount(); i++ )
                {
                                MATH::CVector3 oPointPosition = 
aPointPositions[i];

                                // deform points math here
                                ...

// record the modified point position
                                aPointPositions[i] = oPointPosition;
}

// Write results to mesh
Primitive oPrimitive = oCustomOperator.GetOutputTarget();
oPrimitive.GetGeometry().GetPoints().PutPositionArray( aPointPositions );

// good until here

// Get weight map
ClusterProperty oPushNormalMap = oCustomOperator.GetInputValue( 
portInputWeightMap );
CFloatArray aWeightMapValues;

oPushNormalMap.GetValues( aWeightMapValues );

// re-get points and normals in current deformed state
// ( I have also tried using the input object's primitive - same result)
aPointPositions = oPrimitive.GetGeometry().GetPoints().GetPositionArray();
aPointNormals  = oPrimitive.GetGeometry().GetPoints().GetNormalArray();

                // do push math
                for ( LONG I = 0; I < aPointPositions.GetCount(); i++ )
                {
                                MATH::CVector3 oPointPosition = 
aPointPositions[i];
                                MATH::Cvector3 oPointNormal = aPointNormals[i];

                                // push points math here
                                ...

// record the modified point position
                                aPointPositions[i] = oPointPosition;
                                aPointNormals[i] = oPointNormal;
}

// update the deformed mesh (again)
oPrimitive.GetGeometry().GetPoints().PutPositionArray( aPointPositions );

//----------------------------



Thanks,

Matt



From: softimage-boun...@listproc.autodesk.com 
[mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Hsiao Ming Chia
Sent: Thursday, April 24, 2014 5:35 AM
To: softimage@listproc.autodesk.com
Subject: Re: SDK: port groups in custom operators

Hi Matt,

There is no performance advantage with port groups.
In fact, there is extra logic invoked when connecting to a port group but once 
connected, they are just as fast.

http://softimage.wiki.softimage.com/index.php?title=Custom_Operators_(XSISDK)#1._PortGroups_make_it_easier_to_connect_an_operator_when_it_is_created

Thanks,
Hsiao Ming



-------- Original message --------
From: Matt Lind <ml...@carbinestudios.com<mailto:ml...@carbinestudios.com>>
Date:
To: softimage@listproc.autodesk.com<mailto:softimage@listproc.autodesk.com>
Subject: SDK: port groups in custom operators
Other than the situation of needing an arbitrary number of input or output 
connections, is there any technical reason to put ports into different port 
groups for a custom operator?  Is there a performance advantage?  If so, what's 
the best strategy?

Thanks,

Matt

<<attachment: winmail.dat>>

Reply via email to