diff --git a/Changes b/Changes index daf2b80e6b..cd8971a2c0 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,11 @@ +10.6.x.x (relative to 10.6.0.0a1) +======== + +Breaking Changes +---------------- + +- SmoothSkinningData : Removed, along with all associated Ops and Parameters. + 10.6.0.0a1 (relative to 10.5.15.1) ========== diff --git a/SConstruct b/SConstruct index 9235753937..9c7cf4e2e5 100644 --- a/SConstruct +++ b/SConstruct @@ -600,16 +600,6 @@ o.Add( ( "IECoreScene.MeshMergeOp", os.path.join( "common", "primitive", "mesh", "merge" ) ), ( "IECoreScene.MeshVertexReorderOp", os.path.join( "common", "primitive", "mesh", "vertexReorder" ) ), ( "IECoreScene.MeshPrimitiveShrinkWrapOp", os.path.join( "common", "primitive", "mesh", "shrinkWrap" ) ), - ( "IECoreScene.AddSmoothSkinningInfluencesOp", os.path.join( "rigging", "smoothSkinning", "addInfluences" ) ), - ( "IECoreScene.RemoveSmoothSkinningInfluencesOp", os.path.join( "rigging", "smoothSkinning", "removeInfluences" ) ), - ( "IECoreScene.CompressSmoothSkinningDataOp", os.path.join( "rigging", "smoothSkinning", "compress" ) ), - ( "IECoreScene.DecompressSmoothSkinningDataOp", os.path.join( "rigging", "smoothSkinning", "decompress" ) ), - ( "IECoreScene.NormalizeSmoothSkinningWeightsOp", os.path.join( "rigging", "smoothSkinning", "normalizeWeights" ) ), - ( "IECoreScene.ReorderSmoothSkinningInfluencesOp", os.path.join( "rigging", "smoothSkinning", "reorderInfluences" ) ), - ( "IECoreScene.SmoothSmoothSkinningWeightsOp", os.path.join( "rigging", "smoothSkinning", "smoothWeights" ) ), - ( "IECoreScene.ContrastSmoothSkinningWeightsOp", os.path.join( "rigging", "smoothSkinning", "contrastWeights" ) ), - ( "IECoreScene.LimitSmoothSkinningInfluencesOp", os.path.join( "rigging", "smoothSkinning", "limitInfluences" ) ), - ( "IECoreScene.TransferSmoothSkinningWeightsOp", os.path.join( "rigging", "smoothSkinning", "transferWeights" ) ), ] ) diff --git a/include/IECoreScene/AddSmoothSkinningInfluencesOp.h b/include/IECoreScene/AddSmoothSkinningInfluencesOp.h deleted file mode 100644 index 7423c63ad0..0000000000 --- a/include/IECoreScene/AddSmoothSkinningInfluencesOp.h +++ /dev/null @@ -1,77 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_ADDSMOOTHSKINNINGINFLUENCESOP_H -#define IECORESCENE_ADDSMOOTHSKINNINGINFLUENCESOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The AddSmoothSkinningInfluencesOp adds zero-weighted influences to the SmoothSkinningData. -/// Each new influence requires a name, a pose matrix, and an index representing it's position -/// in the influence list. The new influences will be added one at a time and each index will -/// refer to the influence list at the time that the associated influence is being added. -/// \ingroup skinningGroup -class IECORESCENE_API AddSmoothSkinningInfluencesOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( AddSmoothSkinningInfluencesOp, AddSmoothSkinningInfluencesOpTypeId, IECore::ModifyOp ); - - AddSmoothSkinningInfluencesOp(); - ~AddSmoothSkinningInfluencesOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::StringVectorParameterPtr m_influenceNamesParameter; - IECore::M44fVectorParameterPtr m_influencePoseParameter; - IECore::IntVectorParameterPtr m_indicesParameter; -}; - -IE_CORE_DECLAREPTR( AddSmoothSkinningInfluencesOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_ADDSMOOTHSKINNINGINFLUENCESOP_H diff --git a/include/IECoreScene/CompressSmoothSkinningDataOp.h b/include/IECoreScene/CompressSmoothSkinningDataOp.h deleted file mode 100644 index 353e22f304..0000000000 --- a/include/IECoreScene/CompressSmoothSkinningDataOp.h +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_COMPRESSSMOOTHSKINNINGDATAOP_H -#define IECORESCENE_COMPRESSSMOOTHSKINNINGDATAOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" - -namespace IECoreScene -{ - -/// The CompressSmoothSkinningDataOp compresses SmoothSkinningData by removing weights below a threshold value -/// \ingroup skinningGroup -class IECORESCENE_API CompressSmoothSkinningDataOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( CompressSmoothSkinningDataOp, CompressSmoothSkinningDataOpTypeId, IECore::ModifyOp ); - - CompressSmoothSkinningDataOp(); - ~CompressSmoothSkinningDataOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::FloatParameterPtr m_thresholdParameter; - -}; - -IE_CORE_DECLAREPTR( CompressSmoothSkinningDataOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_COMPRESSSMOOTHSKINNINGDATAOP_H diff --git a/include/IECoreScene/ContrastSmoothSkinningWeightsOp.h b/include/IECoreScene/ContrastSmoothSkinningWeightsOp.h deleted file mode 100644 index b98bc2f6b3..0000000000 --- a/include/IECoreScene/ContrastSmoothSkinningWeightsOp.h +++ /dev/null @@ -1,85 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_CONTRASTSMOOTHSKINNINGWEIGHTSOP_H -#define IECORESCENE_CONTRASTSMOOTHSKINNINGWEIGHTSOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/TypedPrimitiveParameter.h" - -#include "IECore/FrameListParameter.h" -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The ContrastSmoothSkinningWeightsOp applies a parameterised step function on the weights of SmoothSkinningData -/// to increase the contrast between the most important joints from the lesser ones. -/// The shape of the step function varies from linear to a hard step function with the contrast ratio parameter and the -/// middle contrast point is defined by contrast center parameter. -/// \ingroup skinningGroup -class IECORESCENE_API ContrastSmoothSkinningWeightsOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ContrastSmoothSkinningWeightsOp, ContrastSmoothSkinningWeightsOpTypeId, IECore::ModifyOp ); - - ContrastSmoothSkinningWeightsOp(); - ~ContrastSmoothSkinningWeightsOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - class ContrastSmoothStep; - - MeshPrimitiveParameterPtr m_meshParameter; - IECore::FrameListParameterPtr m_vertexIdsParameter; - IECore::FloatParameterPtr m_contrastRatioParameter; - IECore::FloatParameterPtr m_contrastCenterParameter; - IECore::IntParameterPtr m_iterationsParameter; - IECore::BoolParameterPtr m_useLocksParameter; - IECore::BoolVectorParameterPtr m_influenceLocksParameter; -}; - -IE_CORE_DECLAREPTR( ContrastSmoothSkinningWeightsOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_CONTRASTSMOOTHSKINNINGWEIGHTSOP_H diff --git a/include/IECoreScene/DecompressSmoothSkinningDataOp.h b/include/IECoreScene/DecompressSmoothSkinningDataOp.h deleted file mode 100644 index ef88cf987d..0000000000 --- a/include/IECoreScene/DecompressSmoothSkinningDataOp.h +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_DECOMPRESSSMOOTHSKINNINGDATAOP_H -#define IECORESCENE_DECOMPRESSSMOOTHSKINNINGDATAOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" - -namespace IECoreScene -{ - -/// The DecompressSmoothSkinningDataOp decompresses SmoothSkinningData by adding 0 value weights for all missing influences -/// \ingroup skinningGroup -class IECORESCENE_API DecompressSmoothSkinningDataOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( DecompressSmoothSkinningDataOp, DecompressSmoothSkinningDataOpTypeId, IECore::ModifyOp ); - - DecompressSmoothSkinningDataOp(); - ~DecompressSmoothSkinningDataOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - -}; - -IE_CORE_DECLAREPTR( DecompressSmoothSkinningDataOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_DECOMPRESSSMOOTHSKINNINGDATAOP_H diff --git a/include/IECoreScene/LimitSmoothSkinningInfluencesOp.h b/include/IECoreScene/LimitSmoothSkinningInfluencesOp.h deleted file mode 100644 index 7072e1fdfc..0000000000 --- a/include/IECoreScene/LimitSmoothSkinningInfluencesOp.h +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_LIMITSMOOTHSKINNINGINFLUENCESOP_H -#define IECORESCENE_LIMITSMOOTHSKINNINGINFLUENCESOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/FrameListParameter.h" -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The LimitSmoothSkinningInfluencesOp zeros the weight values of SmoothSkinningData for certain influences. -/// This op has several modes of operation. It can zero influences below a minimum weight value, -/// it can impose a maximum number of influences per point, or it can zero specific influences for all points. -/// There is a parameter to control whether the result should be compressed or left as is. Locks can be applied -/// in WeightLimit and MaxInfluences mode to control which influences are affected. -/// \ingroup skinningGroup -class IECORESCENE_API LimitSmoothSkinningInfluencesOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( LimitSmoothSkinningInfluencesOp, LimitSmoothSkinningInfluencesOpTypeId, IECore::ModifyOp ); - - LimitSmoothSkinningInfluencesOp(); - ~LimitSmoothSkinningInfluencesOp() override; - - enum Mode - { - WeightLimit = 0, - MaxInfluences, - Indexed, - }; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::IntParameterPtr m_modeParameter; - IECore::BoolParameterPtr m_compressionParameter; - IECore::FloatParameterPtr m_minWeightParameter; - IECore::IntParameterPtr m_maxInfluencesParameter; - IECore::FrameListParameterPtr m_influenceIndicesParameter; - IECore::BoolParameterPtr m_useLocksParameter; - IECore::BoolVectorParameterPtr m_influenceLocksParameter; -}; - -IE_CORE_DECLAREPTR( LimitSmoothSkinningInfluencesOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_LIMITSMOOTHSKINNINGINFLUENCESOP_H diff --git a/include/IECoreScene/MixSmoothSkinningWeightsOp.h b/include/IECoreScene/MixSmoothSkinningWeightsOp.h deleted file mode 100644 index ca23c53dcd..0000000000 --- a/include/IECoreScene/MixSmoothSkinningWeightsOp.h +++ /dev/null @@ -1,75 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_MIXSMOOTHSKINNINGWEIGHTSOP_H -#define IECORESCENE_MIXSMOOTHSKINNINGWEIGHTSOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/ModifyOp.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The MixSmoothSkinningWeightsOp mixes two sets of SmoothSkinningData using FloatVectorData to interpolate between the weights. -/// Both SmoothSkinningData are required to have the same number of points and influences. The FloatVectorData provided represents -/// interpolation weights for the SmoothSkinningData given to the input parameter. The resulting SmoothSkinningData will be compressed. -/// \ingroup skinningGroup -class IECORESCENE_API MixSmoothSkinningWeightsOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( MixSmoothSkinningWeightsOp, MixSmoothSkinningWeightsOpTypeId, IECore::ModifyOp ); - - MixSmoothSkinningWeightsOp(); - ~MixSmoothSkinningWeightsOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - SmoothSkinningDataParameterPtr m_skinningDataParameter; - IECore::FloatVectorParameterPtr m_mixingWeightsParameter; -}; - -IE_CORE_DECLAREPTR( MixSmoothSkinningWeightsOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_MIXSMOOTHSKINNINGWEIGHTSOP_H diff --git a/include/IECoreScene/NormalizeSmoothSkinningWeightsOp.h b/include/IECoreScene/NormalizeSmoothSkinningWeightsOp.h deleted file mode 100644 index 1b5df38bec..0000000000 --- a/include/IECoreScene/NormalizeSmoothSkinningWeightsOp.h +++ /dev/null @@ -1,74 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_NORMALIZESMOOTHSKINNINGWEIGHTSOP_H -#define IECORESCENE_NORMALIZESMOOTHSKINNINGWEIGHTSOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The NormalizeSmoothSkinningWeightsOp normalizes SmoothSkinningData weights between the existing influences for each point -/// Locks can be applied to the influences and the unlocked weights will be normalized accordingly. -/// \ingroup skinningGroup -class IECORESCENE_API NormalizeSmoothSkinningWeightsOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( NormalizeSmoothSkinningWeightsOp, NormalizeSmoothSkinningWeightsOpTypeId, IECore::ModifyOp ); - - NormalizeSmoothSkinningWeightsOp(); - ~NormalizeSmoothSkinningWeightsOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::BoolParameterPtr m_useLocksParameter; - IECore::BoolVectorParameterPtr m_influenceLocksParameter; -}; - -IE_CORE_DECLAREPTR( NormalizeSmoothSkinningWeightsOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_NORMALIZESMOOTHSKINNINGWEIGHTSOP_H diff --git a/include/IECoreScene/PointSmoothSkinningOp.h b/include/IECoreScene/PointSmoothSkinningOp.h deleted file mode 100644 index d628d22065..0000000000 --- a/include/IECoreScene/PointSmoothSkinningOp.h +++ /dev/null @@ -1,139 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_POINTSMOOTHSKINNINGOP_H -#define IECORESCENE_POINTSMOOTHSKINNINGOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" -#include "IECoreScene/TypedObjectParameter.h" -#include "IECoreScene/TypedPrimitiveParameter.h" - -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/SimpleTypedParameter.h" -#include "IECore/VectorTypedParameter.h" - -#include - -namespace IECoreScene -{ - -/// A PointPrimitiveOp to deform points and normals based on a pose defined by a matrixVector and SmoothSkinningData. -/// This Op can be used to generate smooth deformation effects based on influence objects like joint hierachies. -/// -/// The input Primitive should have a V3fVectorData primitive variable for positions as specified by the positionVar -/// parameter (which defaults to "P"). Optionally one can also deform a normal V3fVectorData primitive variable (which -/// defaults to "N"). These variables must have the same number of elements and must match the number of points in the -/// SmoothSkinningData. -/// \ingroup geometryProcessingGroup -/// \ingroup skinningGroup -class IECORESCENE_API PointSmoothSkinningOp : public IECore::ModifyOp -{ - public: - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( PointSmoothSkinningOp, PointSmoothSkinningOpTypeId, IECore::ModifyOp ); - - - // defines what algorithm to use when calculating the deformation - typedef enum - { - Linear = 0, - // todo: DualQuaternion = 1 - // todo: LinearDualQuaternionMix = 2 - } Blend; - - PointSmoothSkinningOp(); - ~PointSmoothSkinningOp() override; - - /// parameter for the 'position' primvar to be deformed in the input primitive, - /// defaults to "P" - IECore::StringParameter * positionVarParameter(); - const IECore::StringParameter * positionVarParameter() const; - - /// parameter for the 'normal' primvar to be deformed in the input primitive, - /// defaults to "N" - IECore::StringParameter * normalVarParameter(); - const IECore::StringParameter * normalVarParameter() const; - - /// parameter for the smooth skinning data used in the deformation - SmoothSkinningDataParameter * smoothSkinningDataParameter(); - const SmoothSkinningDataParameter * smoothSkinningDataParameter() const; - - /// parameter for the pose that deforms the points, this array of matrices is assumed to be in - /// world space and match the length in the SmoothSkinningData parameter's influencePose - IECore::M44fVectorParameter * deformationPoseParameter(); - const IECore::M44fVectorParameter * deformationPoseParameter() const; - - /// parameter to control if the normals are deformed by the op - IECore::BoolParameter * deformNormalsParameter(); - const IECore::BoolParameter * deformNormalsParameter() const; - - /// parameter that controls which algorithm is used for the deformation of the mesh - IECore::IntParameter * blendParameter(); - const IECore::IntParameter * blendParameter() const; - - /// parameter to map each input vertex index to an index in the smooth skinning data - IECore::IntVectorParameter * refIndicesParameter(); - const IECore::IntVectorParameter * refIndicesParameter() const; - - protected: - - void modify( IECore::Object *object, const IECore::CompoundObject * operands ) override; - - private: - - IECore::StringParameterPtr m_positionVarParameter; - IECore::StringParameterPtr m_normalVarParameter; - SmoothSkinningDataParameterPtr m_smoothSkinningDataParameter; - IECore::IntParameterPtr m_blendParameter; - IECore::BoolParameterPtr m_deformNormalsParameter; - IECore::M44fVectorParameterPtr m_deformationPoseParameter; - IECore::IntVectorParameterPtr m_refIndicesParameter; - - ConstSmoothSkinningDataPtr m_prevSmoothSkinningData; - - struct DeformPositions; - struct DeformNormals; -}; - -IE_CORE_DECLAREPTR( PointSmoothSkinningOp ); - - -} // namespace IECoreScene - -#endif // IECORESCENE_POINTSMOOTHSKINNINGOP_H diff --git a/include/IECoreScene/RemoveSmoothSkinningInfluencesOp.h b/include/IECoreScene/RemoveSmoothSkinningInfluencesOp.h deleted file mode 100644 index 54c1453772..0000000000 --- a/include/IECoreScene/RemoveSmoothSkinningInfluencesOp.h +++ /dev/null @@ -1,82 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_REMOVESMOOTHSKINNINGINFLUENCESOP_H -#define IECORESCENE_REMOVESMOOTHSKINNINGINFLUENCESOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The RemoveSmoothSkinningInfluencesOp removes influences from the SmoothSkinningData, regardless of -/// existing weights. It is the user's responsibility to normalize the resulting SmoothSkinningData if desired. -/// \ingroup skinningGroup -class IECORESCENE_API RemoveSmoothSkinningInfluencesOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( RemoveSmoothSkinningInfluencesOp, RemoveSmoothSkinningInfluencesOpTypeId, IECore::ModifyOp ); - - RemoveSmoothSkinningInfluencesOp(); - ~RemoveSmoothSkinningInfluencesOp() override; - - enum Mode - { - Named = 0, - Indexed, - Weightless - }; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::IntParameterPtr m_modeParameter; - IECore::StringVectorParameterPtr m_influenceNamesParameter; - IECore::IntVectorParameterPtr m_indicesParameter; -}; - -IE_CORE_DECLAREPTR( RemoveSmoothSkinningInfluencesOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_REMOVESMOOTHSKINNINGINFLUENCESOP_H diff --git a/include/IECoreScene/ReorderSmoothSkinningInfluencesOp.h b/include/IECoreScene/ReorderSmoothSkinningInfluencesOp.h deleted file mode 100644 index fe80be2975..0000000000 --- a/include/IECoreScene/ReorderSmoothSkinningInfluencesOp.h +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_REORDERSMOOTHSKINNINGINFLUENCESOP_H -#define IECORESCENE_REORDERSMOOTHSKINNINGINFLUENCESOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -/// The ReorderSmoothSkinningInfluencesOp changes the order of the influences in SmoothSkinningData -/// \ingroup skinningGroup -class IECORESCENE_API ReorderSmoothSkinningInfluencesOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( ReorderSmoothSkinningInfluencesOp, ReorderSmoothSkinningInfluencesOpTypeId, IECore::ModifyOp ); - - ReorderSmoothSkinningInfluencesOp(); - ~ReorderSmoothSkinningInfluencesOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::StringVectorParameterPtr m_reorderedInfluencesParameter; - -}; - -IE_CORE_DECLAREPTR( ReorderSmoothSkinningInfluencesOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_REORDERSMOOTHSKINNINGINFLUENCESOP_H diff --git a/include/IECoreScene/SmoothSkinningData.h b/include/IECoreScene/SmoothSkinningData.h deleted file mode 100644 index 8772c5aa00..0000000000 --- a/include/IECoreScene/SmoothSkinningData.h +++ /dev/null @@ -1,167 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2012, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_SMOOTHSKINNINGDATA_H -#define IECORESCENE_SMOOTHSKINNINGDATA_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/Data.h" -#include "IECore/VectorTypedData.h" - -namespace IECoreScene -{ - -IE_CORE_FORWARDDECLARE( SmoothSkinningData ) - -/// Defines a data class for storing smooth skinning data along with influenceNames and their respective pre-bind matrices. -/// SmoothSkinningData stores bind information for points that can be deformed using multiple weighted transforms. -/// The most common usecase is probably smooth skinning / smooth binding of points on a geometry to a skeleton hierarchy. -/// -/// Consider the following example for some valid SmoothSkinningData: -/// -/// influenceNames = [ infA, infB ] (this is a StringVector) -/// influencePose = [ trfA, trfB ] (this is a M44fVector) -/// pointInfluenceCounts = [ 1, 1, 2, 2, 1 ] -/// pointIndexOffsets = [ 0, 1, 2, 4, 6 ] -/// pointInfluenceIndices = [ 0, 0, 0, 1, 1, 0, 1 ] -/// pointInfluenceWeights = [ 1.0, 1.0, 0.5, 0.5, 0.1, 0.9, 1.0 ] -/// -/// The above SmoothSkinningData (SSD) stores smooth skinning information for 5 points (P) influenced by 2 transforms. -/// The number of points is only implicitly stored and equals the length of the 'pointIndexOffsets' and 'pointInfluenceCounts' arrays. -/// For fast access, the weighting information, which is being held in 'pointInfluenceIndices' and 'pointInfluenceWeights', -/// is stored in flat arrays. To retrieve this information for a specific point, one has to use two helper arrays: -/// 'pointInfluenceCounts' indicates how many influences do influence the point. 'pointIndexOffsets' stores for each -/// point where in the weighting info arrays the data specific to the point is stored. -/// -/// So if we wanted to the skinning info for the 4th point, we'd do the following: -/// -/// pid = 3 -/// pio = pointIndexOffsets[pid] // = 4 -/// pic = pointInfluenceCounts[pid] // = 2 -/// -/// With this information we can now index into the skinning info arrays -/// -/// for (i = pio; i < pio + pic; i++ ) -/// { -/// pii.push_back( pointInfluenceIndices[i] ) -/// piw.push_back( pointInfluenceWeights[i] ) -/// } -/// -/// This gives us the indices of the influences on the point (pii = [1, 0]) and their weighting ( piw = [0.1, 0.9] ). -/// The 'pointInfluenceIndices' are referring to the index of our data in the 'influencePose' and 'influenceNames' -/// arrays. In our example, the 4th point is influenced by 0.9*trfA and 0.1*trfB. The 2nd point is influenced by 1.0*trfA -/// and the third point is influenced by 50% from both infA and infB. -/// \ingroup skinningGroup -class IECORESCENE_API SmoothSkinningData : public IECore::Data -{ - public: - - IE_CORE_DECLAREEXTENSIONOBJECT( SmoothSkinningData, SmoothSkinningDataTypeId, IECore::Data ); - - /// Returns the names of the influence objects, it is used for reference. - const IECore::StringVectorData *influenceNames() const; - IECore::StringVectorData *influenceNames() ; - - /// Returns a pose (an array of matrices) describing the pre-bind, world-space - /// transformation of the influence objects. This array has the same length than'influenceNames'. - const IECore::M44fVectorData *influencePose() const; - IECore::M44fVectorData *influencePose() ; - - /// Returns an array of indices indicating where in the - /// 'pointInfluenceIndices' and 'pointInfluenceWeights' arrays the smooth skinning information - /// for the particular point can be found. The array holds one entry per deformable point. - const IECore::IntVectorData *pointIndexOffsets() const; - IECore::IntVectorData *pointIndexOffsets() ; - - /// Returns an array of counts (one entry per point) indicating how many entries in the - /// 'pointInfluenceIndices' and 'pointInfluenceWeights' arrays from the respective 'pointIndexOffsets' - /// are holding the smooth skinning information for the point. - /// The array holds one entry per deformable point. - const IECore::IntVectorData *pointInfluenceCounts() const; - IECore::IntVectorData *pointInfluenceCounts() ; - - /// Returns an array that holds all influence indices for all points. The length of the array matches - /// the 'pointInfluenceWeights'. The indices are refering to the respective index in the 'influencePose' - /// and 'influenceNames' arrays. - const IECore::IntVectorData *pointInfluenceIndices() const; - IECore::IntVectorData *pointInfluenceIndices() ; - - /// Returns an array that holds all influence weights for all points. The length of the array matches - /// the 'pointInfluenceIndices' length. - const IECore::FloatVectorData *pointInfluenceWeights() const; - IECore::FloatVectorData *pointInfluenceWeights() ; - - /// Assign-All Constructor - SmoothSkinningData( IECore::ConstStringVectorDataPtr influenceNames, - IECore::ConstM44fVectorDataPtr influencePose, - IECore::ConstIntVectorDataPtr pointIndexOffsets, - IECore::ConstIntVectorDataPtr pointInfluenceCounts, - IECore::ConstIntVectorDataPtr pointInfluenceIndices, - IECore::ConstFloatVectorDataPtr pointInfluenceWeights); - - /// Default constructor - SmoothSkinningData(); - - ~SmoothSkinningData() override; - - /// raises an exception if the smooth skinning data is not valid - void validate() const; - - private: - - static const unsigned int m_ioVersion; - - IECore::StringVectorDataPtr m_influenceNames; - IECore::M44fVectorDataPtr m_influencePose; - IECore::IntVectorDataPtr m_pointIndexOffsets; - IECore::IntVectorDataPtr m_pointInfluenceCounts; - IECore::IntVectorDataPtr m_pointInfluenceIndices; - IECore::FloatVectorDataPtr m_pointInfluenceWeights; - - void validateSizes() const; - void validateCounts() const; - void validateIds() const; - void validateOffsets() const; -}; - -IE_CORE_DECLAREPTR( SmoothSkinningData ) - -} // namespace IECoreScene - -#endif // IECORESCENE_SMOOTHSKINNINGDATA_H diff --git a/include/IECoreScene/SmoothSmoothSkinningWeightsOp.h b/include/IECoreScene/SmoothSmoothSkinningWeightsOp.h deleted file mode 100644 index cf1c167ee1..0000000000 --- a/include/IECoreScene/SmoothSmoothSkinningWeightsOp.h +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_SMOOTHSMOOTHSKINNINGWEIGHTSOP_H -#define IECORESCENE_SMOOTHSMOOTHSKINNINGWEIGHTSOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/TypedPrimitiveParameter.h" - -#include "IECore/FrameListParameter.h" -#include "IECore/ModifyOp.h" -#include "IECore/NumericParameter.h" -#include "IECore/VectorTypedParameter.h" - -#include "boost/graph/adjacency_list.hpp" - -namespace IECoreScene -{ - -/// The SmoothSmoothSkinningWeightsOp smooths the weights of SmoothSkinningData using the average weights from -/// connected vertices. The connectivity information is calculated from a MeshPrimitive and the neighbouring weights -/// are averaged and interpolated using the smoothingRatio over any number of iterations. Locks can be applied to the -/// influences per iteration and the unlocked weights will be normalized accordingly. There is an optional vertexIndices -/// parameter which applies smoothing to user chosen vertices only. In this case, the smoothing weights will still be -/// interpolated from all connected vertices, regardless of which vertices have been selected. -/// \ingroup skinningGroup -class IECORESCENE_API SmoothSmoothSkinningWeightsOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( SmoothSmoothSkinningWeightsOp, SmoothSmoothSkinningWeightsOpTypeId, IECore::ModifyOp ); - - SmoothSmoothSkinningWeightsOp(); - ~SmoothSmoothSkinningWeightsOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - typedef boost::adjacency_list Graph; - typedef boost::property_map::type VertexIdMap; - typedef Graph::vertex_descriptor Vertex; - typedef Graph::adjacency_iterator NeighbourIterator; - typedef std::pair NeighbourIteratorRange; - - MeshPrimitiveParameterPtr m_meshParameter; - IECore::FrameListParameterPtr m_vertexIdsParameter; - IECore::FloatParameterPtr m_smoothingRatioParameter; - IECore::IntParameterPtr m_iterationsParameter; - IECore::BoolParameterPtr m_useLocksParameter; - IECore::BoolVectorParameterPtr m_influenceLocksParameter; -}; - -IE_CORE_DECLAREPTR( SmoothSmoothSkinningWeightsOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_SMOOTHSMOOTHSKINNINGWEIGHTSOP_H diff --git a/include/IECoreScene/TransferSmoothSkinningWeightsOp.h b/include/IECoreScene/TransferSmoothSkinningWeightsOp.h deleted file mode 100644 index c9e048ebb3..0000000000 --- a/include/IECoreScene/TransferSmoothSkinningWeightsOp.h +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENE_TRANSFERSMOOTHSKINNINGWEIGHTSOP_H -#define IECORESCENE_TRANSFERSMOOTHSKINNINGWEIGHTSOP_H - -#include "IECoreScene/Export.h" -#include "IECoreScene/TypeIds.h" - -#include "IECore/ModifyOp.h" -#include "IECore/VectorTypedParameter.h" - -namespace IECoreScene -{ - -class IECORESCENE_API TransferSmoothSkinningWeightsOp : public IECore::ModifyOp -{ - public : - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( TransferSmoothSkinningWeightsOp, TransferSmoothSkinningWeightsOpTypeId, IECore::ModifyOp ); - - TransferSmoothSkinningWeightsOp(); - ~TransferSmoothSkinningWeightsOp() override; - - protected : - - void modify( IECore::Object *object, const IECore::CompoundObject *operands ) override; - - private : - - IECore::StringParameterPtr m_targetInfluenceNameParameter; - IECore::StringVectorParameterPtr m_sourceInfluenceNamesParameter; - -}; - -IE_CORE_DECLAREPTR( TransferSmoothSkinningWeightsOp ); - -} // namespace IECoreScene - -#endif // IECORESCENE_TRANSFERSMOOTHSKINNINGWEIGHTSOP_H diff --git a/include/IECoreScene/TypeIds.h b/include/IECoreScene/TypeIds.h index fd7fba984f..41c2ed9d9b 100644 --- a/include/IECoreScene/TypeIds.h +++ b/include/IECoreScene/TypeIds.h @@ -106,26 +106,26 @@ enum TypeId CurvesPrimitiveOpTypeId = 108063, CurveLineariserTypeId = 108064, CurveTangentsOpTypeId = 108065, - SmoothSkinningDataTypeId = 108066, + SmoothSkinningDataTypeId = 108066, // Obsolete, available for reuse FaceVaryingPromotionOpTypeId = 108067, MeshDistortionsOpTypeId = 108068, PointVelocityDisplaceOpTypeId = 108069, // Obsolete, available for reuse - SmoothSkinningDataParameterTypeId = 108070, - CompressSmoothSkinningDataOpTypeId = 108071, - DecompressSmoothSkinningDataOpTypeId = 108072, - NormalizeSmoothSkinningWeightsOpTypeId = 108073, - ReorderSmoothSkinningInfluencesOpTypeId = 108074, - RemoveSmoothSkinningInfluencesOpTypeId = 108075, - SmoothSmoothSkinningWeightsOpTypeId = 108076, - MixSmoothSkinningWeightsOpTypeId = 108077, - PointSmoothSkinningOpTypeId = 108078, - AddSmoothSkinningInfluencesOpTypeId = 108079, - LimitSmoothSkinningInfluencesOpTypeId = 108080, + SmoothSkinningDataParameterTypeId = 108070, // Obsolete, available for reuse + CompressSmoothSkinningDataOpTypeId = 108071, // Obsolete, available for reuse + DecompressSmoothSkinningDataOpTypeId = 108072, // Obsolete, available for reuse + NormalizeSmoothSkinningWeightsOpTypeId = 108073, // Obsolete, available for reuse + ReorderSmoothSkinningInfluencesOpTypeId = 108074, // Obsolete, available for reuse + RemoveSmoothSkinningInfluencesOpTypeId = 108075, // Obsolete, available for reuse + SmoothSmoothSkinningWeightsOpTypeId = 108076, // Obsolete, available for reuse + MixSmoothSkinningWeightsOpTypeId = 108077, // Obsolete, available for reuse + PointSmoothSkinningOpTypeId = 108078, // Obsolete, available for reuse + AddSmoothSkinningInfluencesOpTypeId = 108079, // Obsolete, available for reuse + LimitSmoothSkinningInfluencesOpTypeId = 108080, // Obsolete, available for reuse PointsPrimitiveEvaluatorTypeId = 108081, PointsMotionOpTypeId = 108082, // Obsolete, available for reuse ShaderNetworkTypeId = 108083, LightTypeId = 108084, // Obsolete, available for reuse - ContrastSmoothSkinningWeightsOpTypeId = 108085, + ContrastSmoothSkinningWeightsOpTypeId = 108085, // Obsolete, available for reuse PointDistributionOpTypeId = 108086, DiskPrimitiveTypeId = 108087, MeshFaceFilterOpTypeId = 108088, @@ -136,7 +136,7 @@ enum TypeId ExternalProceduralTypeId = 108093, OutputTypeId = 108094, SceneCacheTypeId = 108095, - TransferSmoothSkinningWeightsOpTypeId = 108096, + TransferSmoothSkinningWeightsOpTypeId = 108096, // Obsolete, available for reuse RenderableParameterTypeId = 108097, LastCoreSceneTypeId = 108999 }; diff --git a/include/IECoreScene/TypedObjectParameter.h b/include/IECoreScene/TypedObjectParameter.h index 3f2ca49831..832ee00c46 100644 --- a/include/IECoreScene/TypedObjectParameter.h +++ b/include/IECoreScene/TypedObjectParameter.h @@ -43,17 +43,14 @@ namespace IECoreScene IE_CORE_FORWARDDECLARE( Renderable ) IE_CORE_FORWARDDECLARE( Shader ) IE_CORE_FORWARDDECLARE( VisibleRenderable ) -IE_CORE_FORWARDDECLARE( SmoothSkinningData ) typedef IECore::TypedObjectParameter RenderableParameter; typedef IECore::TypedObjectParameter ShaderParameter; typedef IECore::TypedObjectParameter VisibleRenderableParameter; -typedef IECore::TypedObjectParameter SmoothSkinningDataParameter; IE_CORE_DECLAREPTR( RenderableParameter ); IE_CORE_DECLAREPTR( ShaderParameter ); IE_CORE_DECLAREPTR( VisibleRenderableParameter ); -IE_CORE_DECLAREPTR( SmoothSkinningDataParameter ); } // namespace IECoreScene diff --git a/src/IECoreScene/AddSmoothSkinningInfluencesOp.cpp b/src/IECoreScene/AddSmoothSkinningInfluencesOp.cpp deleted file mode 100644 index 1b08dc17a1..0000000000 --- a/src/IECoreScene/AddSmoothSkinningInfluencesOp.cpp +++ /dev/null @@ -1,148 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/AddSmoothSkinningInfluencesOp.h" - -#include "IECoreScene/ReorderSmoothSkinningInfluencesOp.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( AddSmoothSkinningInfluencesOp ); - -AddSmoothSkinningInfluencesOp::AddSmoothSkinningInfluencesOp() - : ModifyOp( - "The AddSmoothSkinningInfluencesOp adds zero-weighted influences to the SmoothSkinningData.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_influenceNamesParameter = new StringVectorParameter( - "influenceNames", - "Names of the new influences", - new StringVectorData - ); - - m_influencePoseParameter = new M44fVectorParameter( - "influencePose", - "Pose matrices for the new influences", - new M44fVectorData - ); - - m_indicesParameter = new IntVectorParameter( - "indices", - "Per-new-influence indices into the running influence list at the time each new influence is added", - new IntVectorData - ); - - parameters()->addParameter( m_influenceNamesParameter ); - parameters()->addParameter( m_influencePoseParameter ); - parameters()->addParameter( m_indicesParameter ); -} - -AddSmoothSkinningInfluencesOp::~AddSmoothSkinningInfluencesOp() -{ -} - -void AddSmoothSkinningInfluencesOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &newNames = m_influenceNamesParameter->getTypedValue(); - const std::vector &newPoseData = m_influencePoseParameter->getTypedValue(); - const std::vector &indices = m_indicesParameter->getTypedValue(); - - std::vector &influenceNames = skinningData->influenceNames()->writable(); - std::vector &influencePoseData = skinningData->influencePose()->writable(); - - // make sure the parameter values are the same length - if ( newNames.size() != newPoseData.size() ) - { - throw IECore::Exception( "AddSmoothSkinningInfluencesOp: the influenceNames and influencePose parameters are not the same size" ); - } - - if ( newNames.size() != indices.size() ) - { - throw IECore::Exception( "AddSmoothSkinningInfluencesOp: the influenceNames and indices parameters are not the same size" ); - } - - // determine the proper order of influences - std::vector finalOrder( influenceNames.begin(), influenceNames.end() ); - for ( unsigned i=0; i < newNames.size(); i++ ) - { - std::string name = newNames[i]; - - if ( find( influenceNames.begin(), influenceNames.end(), name ) != influenceNames.end() ) - { - throw IECore::Exception( ( boost::format( "AddSmoothSkinningInfluencesOp: \"%s\" is already an influence" ) % name ).str() ); - } - - if ( indices[i] > (int)finalOrder.size() ) - { - throw IECore::Exception( ( boost::format( "AddSmoothSkinningInfluencesOp: \"%d\" is outside the range of valid indices" ) % indices[i] ).str() ); - } - else if ( indices[i] == (int)finalOrder.size() ) - { - finalOrder.push_back( name ); - } - else - { - finalOrder.insert( finalOrder.begin() + indices[i], name ); - } - } - - // add new influences to the end - for ( unsigned i=0; i < newNames.size(); i++ ) - { - influenceNames.push_back( newNames[i] ); - influencePoseData.push_back( newPoseData[i] ); - } - - // reorder the influences - ReorderSmoothSkinningInfluencesOp reorderOp; - reorderOp.inputParameter()->setValidatedValue( skinningData ); - reorderOp.copyParameter()->setTypedValue( false ); - reorderOp.parameters()->parameter( "reorderedInfluenceNames" )->setTypedValue( finalOrder ); - reorderOp.operate(); -} diff --git a/src/IECoreScene/CompressSmoothSkinningDataOp.cpp b/src/IECoreScene/CompressSmoothSkinningDataOp.cpp deleted file mode 100644 index 56de940bf1..0000000000 --- a/src/IECoreScene/CompressSmoothSkinningDataOp.cpp +++ /dev/null @@ -1,121 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" - -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( CompressSmoothSkinningDataOp ); - -CompressSmoothSkinningDataOp::CompressSmoothSkinningDataOp() - : ModifyOp( - "The CompressSmoothSkinningDataOp compresses SmoothSkinningData by removing weights below a threshold value.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_thresholdParameter = new FloatParameter( - "threshold", - "The value at which weights will be discarded during compression", - 0.0 - ); - - parameters()->addParameter( m_thresholdParameter ); -} - -CompressSmoothSkinningDataOp::~CompressSmoothSkinningDataOp() -{ -} - -void CompressSmoothSkinningDataOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const float threshold = m_thresholdParameter->getNumericValue(); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - const std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->readable(); - - std::vector newOffsets; - std::vector newCounts; - std::vector newIndices; - std::vector newWeights; - - int offset = 0; - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - int count = 0; - - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - float weight = pointInfluenceWeights[current]; - - if ( weight > threshold ) - { - newIndices.push_back( pointInfluenceIndices[current] ); - newWeights.push_back( weight ); - count++; - } - } - - newOffsets.push_back( offset ); - newCounts.push_back( count ); - offset += count; - } - - // replace the vectors on the SmoothSkinningData - if ( newWeights.size() != pointInfluenceWeights.size() ) - { - skinningData->pointIndexOffsets()->writable().swap( newOffsets ); - skinningData->pointInfluenceCounts()->writable().swap( newCounts ); - skinningData->pointInfluenceIndices()->writable().swap( newIndices ); - skinningData->pointInfluenceWeights()->writable().swap( newWeights ); - } -} diff --git a/src/IECoreScene/ContrastSmoothSkinningWeightsOp.cpp b/src/IECoreScene/ContrastSmoothSkinningWeightsOp.cpp deleted file mode 100644 index 1dcd75bea9..0000000000 --- a/src/IECoreScene/ContrastSmoothSkinningWeightsOp.cpp +++ /dev/null @@ -1,264 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/ContrastSmoothSkinningWeightsOp.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" -#include "IECoreScene/NormalizeSmoothSkinningWeightsOp.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Interpolator.h" -#include "IECore/Math.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( ContrastSmoothSkinningWeightsOp ); - -ContrastSmoothSkinningWeightsOp::ContrastSmoothSkinningWeightsOp() - : ModifyOp( - "The ContrastSmoothSkinningWeightsOp contrasts the weights of SmoothSkinningData by applying a custom step function on the weights. This op does not normalize the weights.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_meshParameter = new MeshPrimitiveParameter( - "mesh", - "The mesh primitive corresponding to the input SmoothSkinningData", - new MeshPrimitive - ); - - m_vertexIdsParameter = new FrameListParameter( - "vertexIndices", - "The indices of the vertices to smooth. All vertices will be smoothed if this parameter is empty", - "" - ); - - m_contrastRatioParameter = new FloatParameter( - "contrastRatio", - "Controls the level of contrast. Interpolates between linear function and smooth step function.", - 1, - 0.0, - 1.0 - ); - - m_contrastCenterParameter = new FloatParameter( - "contrastCenter", - "Sets the middle value for the contrast. Weights lower than that will tend zero and the higher ones will tend to one.", - 0.5, - 1e-3, - 1.0 - 1e-3 - ); - - m_iterationsParameter = new IntParameter( - "iterations", - "The number of iterations to perform the contrast operation.", - 3, - 1 - ); - - m_useLocksParameter = new BoolParameter( - "applyLocks", - "Whether or not influenceLocks should be applied", - true - ); - - m_influenceLocksParameter = new BoolVectorParameter( - "influenceLocks", - "A per-influence list of lock values", - new BoolVectorData - ); - - parameters()->addParameter( m_meshParameter ); - parameters()->addParameter( m_vertexIdsParameter ); - parameters()->addParameter( m_contrastRatioParameter ); - parameters()->addParameter( m_contrastCenterParameter ); - parameters()->addParameter( m_iterationsParameter ); - parameters()->addParameter( m_useLocksParameter ); - parameters()->addParameter( m_influenceLocksParameter ); -} - -ContrastSmoothSkinningWeightsOp::~ContrastSmoothSkinningWeightsOp() -{ -} - -// Custom smoothstep class. Defines the neutral center point, interpolates it with the linear function and applies multiple iterations. -class ContrastSmoothSkinningWeightsOp::ContrastSmoothStep -{ - public: - - ContrastSmoothStep( int iterations, float ratio, float center ) : - m_iterations(iterations), m_ratio(ratio), m_center(center) - { - m_firstHalfScale = 0.5 / m_center; - m_secondHalfScale = 0.5 / (1.0 - m_center); - m_norm = 0.5*m_firstHalfScale+0.5*m_secondHalfScale; - } - - float operator()( float value ) - { - for ( int i = 0; i < m_iterations; i++ ) - { - float result; - if ( value >= m_center ) - { - result = ((smoothstep(0.0,1.0,(value-m_center)*m_secondHalfScale+0.5) - 0.5) * m_firstHalfScale + m_secondHalfScale*0.5) / m_norm; - } - else - { - result = (smoothstep(0.0,1.0,(value-m_center)*m_firstHalfScale+0.5) * m_secondHalfScale) / m_norm; - } - value = m_ratio*result + (1-m_ratio)*value; - } - return value; - } - - private : - - int m_iterations; - float m_ratio; - float m_center; - float m_firstHalfScale; - float m_secondHalfScale; - float m_norm; -}; - -void ContrastSmoothSkinningWeightsOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - // \todo: remove decompression/compression. - // decompress - DecompressSmoothSkinningDataOp decompressionOp; - decompressionOp.inputParameter()->setValidatedValue( skinningData ); - decompressionOp.copyParameter()->setTypedValue( false ); - decompressionOp.operate(); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - int numSsdVerts = pointIndexOffsets.size(); - - std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - - const MeshPrimitive *mesh = runTimeCast( m_meshParameter->getValidatedValue() ); - if ( !mesh ) - { - throw IECore::Exception( "ContrastSmoothSkinningWeightsOp: The given mesh is not valid" ); - } - int numMeshVerts = mesh->variableSize( PrimitiveVariable::Vertex ); - - // make sure the mesh matches the skinning data - if ( numMeshVerts != numSsdVerts ) - { - throw IECore::Exception( "ContrastSmoothSkinningWeightsOp: The input SmoothSkinningData and mesh have a different number of vertices" ); - } - - bool useLocks = m_useLocksParameter->getTypedValue(); - std::vector &locks = m_influenceLocksParameter->getTypedValue(); - - // make sure there is one lock per influence - if ( useLocks && ( locks.size() != skinningData->influenceNames()->readable().size() ) ) - { - throw IECore::Exception( "ContrastSmoothSkinningWeightsOp: There must be exactly one lock per influence" ); - } - - if ( !useLocks ) - { - locks.clear(); - locks.resize( skinningData->influenceNames()->readable().size(), false ); - } - - std::vector vertexIds; - m_vertexIdsParameter->getFrameListValue()->asList( vertexIds ); - - // make sure all vertex ids are valid - for ( unsigned i=0; i < vertexIds.size(); i++ ) - { - if ( vertexIds[i] > numSsdVerts ) - { - throw IECore::Exception( ( boost::format( "ContrastSmoothSkinningWeightsOp: VertexId \"%d\" is outside the range of the SmoothSkinningData and mesh" ) % vertexIds[i] ).str() ); - } - } - - float contrastRatio = m_contrastRatioParameter->getNumericValue(); - float contrastCenter = m_contrastCenterParameter->getNumericValue(); - int numIterations = m_iterationsParameter->getNumericValue(); - - ContrastSmoothStep contrastFunction( numIterations, contrastRatio, contrastCenter ); - - // an empty vertexId list means we operate over all vertices - if ( vertexIds.size() == 0 ) - { - for ( unsigned int i=0; i < pointInfluenceWeights.size(); i++ ) - { - unsigned int current = i; - if ( !locks[ pointInfluenceIndices[current] ] ) - { - pointInfluenceWeights[current] = contrastFunction( pointInfluenceWeights[ current ] ); - } - } - } - else - { - // apply contrast with the per-influence locks - for ( unsigned i=0; i < vertexIds.size(); i++ ) - { - int currentVertId = vertexIds[i]; - for ( int j=0; j < pointInfluenceCounts[currentVertId]; j++ ) - { - int current = pointIndexOffsets[currentVertId] + j; - if ( !locks[ pointInfluenceIndices[current] ] ) - { - pointInfluenceWeights[current] = contrastFunction( pointInfluenceWeights[ current ] ); - } - } - } - } - - // re-compress - CompressSmoothSkinningDataOp compressionOp; - compressionOp.inputParameter()->setValidatedValue( skinningData ); - compressionOp.copyParameter()->setTypedValue( false ); - compressionOp.operate(); -} diff --git a/src/IECoreScene/DecompressSmoothSkinningDataOp.cpp b/src/IECoreScene/DecompressSmoothSkinningDataOp.cpp deleted file mode 100644 index 9708d20ebc..0000000000 --- a/src/IECoreScene/DecompressSmoothSkinningDataOp.cpp +++ /dev/null @@ -1,117 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" - -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( DecompressSmoothSkinningDataOp ); - -DecompressSmoothSkinningDataOp::DecompressSmoothSkinningDataOp() - : ModifyOp( - "The DecompressSmoothSkinningDataOp decompresses SmoothSkinningData by adding 0 value weights for all missing influences", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ -} - -DecompressSmoothSkinningDataOp::~DecompressSmoothSkinningDataOp() -{ -} - -void DecompressSmoothSkinningDataOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &influenceNames = skinningData->influenceNames()->readable(); - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - const std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->readable(); - - std::vector newOffsets; - std::vector newCounts; - std::vector newIndices; - std::vector newWeights; - - int offset = 0; - int numInfluences = influenceNames.size(); - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - const std::vector::const_iterator first = pointInfluenceIndices.begin() + pointIndexOffsets[i]; - const std::vector::const_iterator last = first + pointInfluenceCounts[i]; - - for ( int j=0; j < numInfluences; j++ ) - { - newIndices.push_back( j ); - - const std::vector::const_iterator location = find( first, last, j ); - if ( location != last ) - { - newWeights.push_back( pointInfluenceWeights[ location - pointInfluenceIndices.begin() ] ); - } - else - { - newWeights.push_back( 0.0f ); - } - } - - newOffsets.push_back( offset ); - newCounts.push_back( numInfluences ); - offset += numInfluences; - } - - // replace the vectors on the SmoothSkinningData - if ( newWeights.size() != pointInfluenceWeights.size() ) - { - skinningData->pointIndexOffsets()->writable().swap( newOffsets ); - skinningData->pointInfluenceCounts()->writable().swap( newCounts ); - skinningData->pointInfluenceIndices()->writable().swap( newIndices ); - skinningData->pointInfluenceWeights()->writable().swap( newWeights ); - } -} diff --git a/src/IECoreScene/LimitSmoothSkinningInfluencesOp.cpp b/src/IECoreScene/LimitSmoothSkinningInfluencesOp.cpp deleted file mode 100644 index 23d2acef4b..0000000000 --- a/src/IECoreScene/LimitSmoothSkinningInfluencesOp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/LimitSmoothSkinningInfluencesOp.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( LimitSmoothSkinningInfluencesOp ); - -LimitSmoothSkinningInfluencesOp::LimitSmoothSkinningInfluencesOp() - : ModifyOp( - "The LimitSmoothSkinningInfluencesOp zeros the weight values of SmoothSkinningData for certain influences.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - IntParameter::PresetsContainer modePresets; - modePresets.push_back( IntParameter::Preset( "WeightLimit", LimitSmoothSkinningInfluencesOp::WeightLimit ) ); - modePresets.push_back( IntParameter::Preset( "MaxInfluences", LimitSmoothSkinningInfluencesOp::MaxInfluences ) ); - modePresets.push_back( IntParameter::Preset( "Indexed", LimitSmoothSkinningInfluencesOp::Indexed ) ); - - m_modeParameter = new IntParameter( - "mode", - "The mode of influence limiting. Options are to impose a minimum weight, a maximum number of influences per point, or to zero specific influences for all points", - LimitSmoothSkinningInfluencesOp::WeightLimit, - LimitSmoothSkinningInfluencesOp::WeightLimit, - LimitSmoothSkinningInfluencesOp::Indexed, - modePresets, - true - ); - - m_compressionParameter = new BoolParameter( - "compressResult", - "True if the result should be compressed using the CompressSmoothSkinningDataOp", - true - ); - - m_minWeightParameter = new FloatParameter( - "minWeight", - "The minimum weight an influence is allowed per point. This parameter is only used in WeightLimit mode", - 0.001f, - 0.0f - ); - - m_maxInfluencesParameter = new IntParameter( - "maxInfluences", - "The maximum number of influences per point. This parameter is only used in MaxInfluences mode", - 3, - 0 - ); - - m_influenceIndicesParameter = new FrameListParameter( - "influenceIndices", - "The indices of influences to zero corresponding to the names in input.influenceNames(). This parameter is only used in Indexed mode", - "" - ); - - m_useLocksParameter = new BoolParameter( - "applyLocks", - "Whether or not influenceLocks should be applied", - true - ); - - m_influenceLocksParameter = new BoolVectorParameter( - "influenceLocks", - "A per-influence list of lock values", - new BoolVectorData - ); - - parameters()->addParameter( m_modeParameter ); - parameters()->addParameter( m_compressionParameter ); - parameters()->addParameter( m_minWeightParameter ); - parameters()->addParameter( m_maxInfluencesParameter ); - parameters()->addParameter( m_influenceIndicesParameter ); - parameters()->addParameter( m_useLocksParameter ); - parameters()->addParameter( m_influenceLocksParameter ); -} - -LimitSmoothSkinningInfluencesOp::~LimitSmoothSkinningInfluencesOp() -{ -} - -void LimitSmoothSkinningInfluencesOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - - std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - - bool useLocks = m_useLocksParameter->getTypedValue(); - std::vector &locks = m_influenceLocksParameter->getTypedValue(); - - int mode = m_modeParameter->getNumericValue(); - - // make sure there is one lock per influence - if ( useLocks && ( locks.size() != skinningData->influenceNames()->readable().size() ) && ( mode != LimitSmoothSkinningInfluencesOp::Indexed ) ) - { - throw IECore::Exception( "LimitSmoothSkinningInfluencesOp: There must be exactly one lock per influence" ); - } - - if ( !useLocks ) - { - locks.clear(); - locks.resize( skinningData->influenceNames()->readable().size(), false ); - } - - // Limit influences based on minumum allowable weight - if ( mode == LimitSmoothSkinningInfluencesOp::WeightLimit ) - { - float minWeight = m_minWeightParameter->getNumericValue(); - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - - if ( !locks[ pointInfluenceIndices[current] ] && (pointInfluenceWeights[current] < minWeight) ) - { - pointInfluenceWeights[current] = 0.0f; - } - } - } - } - // Limit the number of influences per point - else if ( mode == LimitSmoothSkinningInfluencesOp::MaxInfluences ) - { - int maxInfluences = m_maxInfluencesParameter->getNumericValue(); - std::vector influencesToLimit; - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - int numToLimit = pointInfluenceCounts[i] - maxInfluences; - if ( numToLimit <= 0 ) - { - continue; - } - - influencesToLimit.clear(); - - for ( int j=0; j < numToLimit; j++ ) - { - int indexOfMin = -1; - float minWeight = std::numeric_limits::max(); - - for ( int k=0; k < pointInfluenceCounts[i]; k++ ) - { - int current = pointIndexOffsets[i] + k; - - if ( locks[ pointInfluenceIndices[current] ] || find( influencesToLimit.begin(), influencesToLimit.end(), current ) != influencesToLimit.end() ) - { - continue; - } - - float weight = pointInfluenceWeights[current]; - - if ( weight < minWeight ) - { - minWeight = weight; - indexOfMin = current; - } - } - - if ( indexOfMin == -1 ) - { - break; - } - - influencesToLimit.push_back( indexOfMin ); - } - - for ( unsigned j=0; j < influencesToLimit.size(); j++ ) - { - pointInfluenceWeights[ influencesToLimit[j] ] = 0.0f; - } - } - } - // Zero specific influences for all points - else if ( mode == LimitSmoothSkinningInfluencesOp::Indexed ) - { - std::vector indicesToLimit; - m_influenceIndicesParameter->getFrameListValue()->asList( indicesToLimit ); - std::vector limitIndex( skinningData->influenceNames()->readable().size(), false ); - for ( unsigned i=0; i < indicesToLimit.size(); i++ ) - { - limitIndex[ indicesToLimit[i] ] = true; - } - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - - if ( limitIndex[ pointInfluenceIndices[current] ] ) - { - pointInfluenceWeights[current] = 0.0f; - } - } - } - } - else - { - throw IECore::Exception( ( boost::format( "LimitSmoothSkinningInfluencesOp: \"%d\" is not a recognized mode" ) % mode ).str() ); - } - - if ( m_compressionParameter->getTypedValue() ) - { - CompressSmoothSkinningDataOp compressionOp; - compressionOp.inputParameter()->setValidatedValue( skinningData ); - compressionOp.copyParameter()->setTypedValue( false ); - compressionOp.operate(); - } -} diff --git a/src/IECoreScene/MixSmoothSkinningWeightsOp.cpp b/src/IECoreScene/MixSmoothSkinningWeightsOp.cpp deleted file mode 100644 index d3e72c4d71..0000000000 --- a/src/IECoreScene/MixSmoothSkinningWeightsOp.cpp +++ /dev/null @@ -1,161 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/MixSmoothSkinningWeightsOp.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" -#include "IECoreScene/SmoothSkinningData.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Interpolator.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( MixSmoothSkinningWeightsOp ); - -MixSmoothSkinningWeightsOp::MixSmoothSkinningWeightsOp() - : ModifyOp( - "The MixSmoothSkinningWeightsOp mixes two sets of SmoothSkinningData using FloatVectorData to interpolate between the weights.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_skinningDataParameter = new SmoothSkinningDataParameter( - "skinningDataToMix", - "The SmoothSkinningData to mix with the input SmoothSkinningData", - new SmoothSkinningData - ); - - m_mixingWeightsParameter = new FloatVectorParameter( - "mixingWeights", - "The per-influence weights for mixing input with skinningDataToMix", - new FloatVectorData - ); - - parameters()->addParameter( m_skinningDataParameter ); - parameters()->addParameter( m_mixingWeightsParameter ); -} - -MixSmoothSkinningWeightsOp::~MixSmoothSkinningWeightsOp() -{ -} - -void MixSmoothSkinningWeightsOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - SmoothSkinningData *origMixingData = runTimeCast( m_skinningDataParameter->getValidatedValue() ); - if ( !origMixingData ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix is not valid" ); - } - - assert( origMixingData ); - - // make sure the number of influences matches - if ( origMixingData->influenceNames()->readable().size() != skinningData->influenceNames()->readable().size() ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix and input have different numbers of influences" ); - } - - std::vector &mixingWeights = m_mixingWeightsParameter->getTypedValue(); - - // make sure there is one mixing weight per influence - if ( mixingWeights.size() != skinningData->influenceNames()->readable().size() ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: There must be exactly one mixing weight per influence" ); - } - - // decompress both sets of skinning data - DecompressSmoothSkinningDataOp decompressionOp; - decompressionOp.inputParameter()->setValidatedValue( skinningData ); - decompressionOp.copyParameter()->setTypedValue( false ); - decompressionOp.operate(); - decompressionOp.inputParameter()->setValidatedValue( origMixingData ); - decompressionOp.copyParameter()->setTypedValue( true ); - decompressionOp.operate(); - const SmoothSkinningData *mixingData = runTimeCast( decompressionOp.resultParameter()->getValidatedValue() ); - if ( !mixingData ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix did not decompress correctly" ); - } - - // make sure everything matches except the weights - if ( *(mixingData->pointIndexOffsets()) != *(skinningData->pointIndexOffsets()) ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix and input have different pointIndexOffsets when decompressed" ); - } - if ( *(mixingData->pointInfluenceCounts()) != *(skinningData->pointInfluenceCounts()) ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix and input have different pointInfluenceCounts when decompressed" ); - } - if ( *(mixingData->pointInfluenceIndices()) != *(skinningData->pointInfluenceIndices()) ) - { - throw IECore::Exception( "MixSmoothSkinningWeightsOp: skinningDataToMix and input have different pointInfluenceIndices when decompressed" ); - } - - const std::vector &inputIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &inputInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &inputInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - - std::vector &inputInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - const std::vector &mixingInfluenceWeights = mixingData->pointInfluenceWeights()->readable(); - - LinearInterpolator lerp; - - // mix the weights - for ( unsigned i=0; i < inputIndexOffsets.size(); i++ ) - { - for ( int j=0; j < inputInfluenceCounts[i]; j++ ) - { - int current = inputIndexOffsets[i] + j; - - lerp( mixingInfluenceWeights[current], inputInfluenceWeights[current], mixingWeights[ inputInfluenceIndices[current] ], inputInfluenceWeights[current] ); - } - } - - // re-compress the input data - CompressSmoothSkinningDataOp compressionOp; - compressionOp.inputParameter()->setValidatedValue( skinningData ); - compressionOp.copyParameter()->setTypedValue( false ); - compressionOp.operate(); -} diff --git a/src/IECoreScene/NormalizeSmoothSkinningWeightsOp.cpp b/src/IECoreScene/NormalizeSmoothSkinningWeightsOp.cpp deleted file mode 100644 index 8cb64c75ea..0000000000 --- a/src/IECoreScene/NormalizeSmoothSkinningWeightsOp.cpp +++ /dev/null @@ -1,144 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/NormalizeSmoothSkinningWeightsOp.h" - -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( NormalizeSmoothSkinningWeightsOp ); - -NormalizeSmoothSkinningWeightsOp::NormalizeSmoothSkinningWeightsOp() - : ModifyOp( - "The NormalizeSmoothSkinningWeightsOp normalizes SmoothSkinningData weights between the existing influences for each point", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_useLocksParameter = new BoolParameter( - "applyLocks", - "Whether or not influenceLocks should be applied", - false - ); - - m_influenceLocksParameter = new BoolVectorParameter( - "influenceLocks", - "A per-influence list of lock values", - new BoolVectorData - ); - - parameters()->addParameter( m_useLocksParameter ); - parameters()->addParameter( m_influenceLocksParameter ); -} - -NormalizeSmoothSkinningWeightsOp::~NormalizeSmoothSkinningWeightsOp() -{ -} - -void NormalizeSmoothSkinningWeightsOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - - std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - - bool useLocks = m_useLocksParameter->getTypedValue(); - std::vector &locks = m_influenceLocksParameter->getTypedValue(); - std::vector unlockedIndices; - - // make sure there is one lock per influence - if ( useLocks && ( locks.size() != skinningData->influenceNames()->readable().size() ) ) - { - throw IECore::Exception( "NormalizeSmoothSkinningWeightsOp: There must be exactly one lock per influence" ); - } - - if ( !useLocks ) - { - locks.clear(); - locks.resize( skinningData->influenceNames()->readable().size(), false ); - } - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - unlockedIndices.clear(); - float totalLockedWeights = 0.0f; - float totalUnlockedWeights = 0.0f; - - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - - if ( locks[ pointInfluenceIndices[current] ] ) - { - totalLockedWeights += pointInfluenceWeights[current]; - } - else - { - totalUnlockedWeights += pointInfluenceWeights[current]; - unlockedIndices.push_back( current ); - } - } - - float remainingWeight = 1.0f - totalLockedWeights; - - if ( (remainingWeight == 0.0f) || (totalUnlockedWeights == 0.0f) ) - { - for ( unsigned j=0; j < unlockedIndices.size(); j++ ) - { - pointInfluenceWeights[ unlockedIndices[j] ] = 0.0f; - } - } - else - { - for ( unsigned j=0; j < unlockedIndices.size(); j++ ) - { - pointInfluenceWeights[ unlockedIndices[j] ] = (pointInfluenceWeights[ unlockedIndices[j] ] * remainingWeight) / totalUnlockedWeights; - } - } - } -} diff --git a/src/IECoreScene/PointSmoothSkinningOp.cpp b/src/IECoreScene/PointSmoothSkinningOp.cpp deleted file mode 100644 index 2e5e09150c..0000000000 --- a/src/IECoreScene/PointSmoothSkinningOp.cpp +++ /dev/null @@ -1,494 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2009, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/PointSmoothSkinningOp.h" - -#include "IECoreScene/MeshPrimitive.h" -#include "IECoreScene/PointsPrimitive.h" -#include "IECoreScene/PrimitiveEvaluator.h" -#include "IECoreScene/SmoothSkinningData.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/DespatchTypedData.h" -#include "IECore/ObjectParameter.h" -#include "IECore/RunTimeTyped.h" -#include "IECore/VectorOps.h" -#include "IECore/VectorTypedData.h" - -#include "boost/format.hpp" - -#include "tbb/parallel_for.h" - -using namespace IECore; -using namespace IECoreScene; -using namespace Imath; -using namespace std; - -IE_CORE_DEFINERUNTIMETYPED( PointSmoothSkinningOp ); - -PointSmoothSkinningOp::PointSmoothSkinningOp() : - ModifyOp( - "Deforms points and normals based on a pose and SmoothSkinningData.", - new PrimitiveParameter( - "result", - "The updated Primitive with deformed points and normals.", - new PointsPrimitive() - ), - new PrimitiveParameter( - "input", - "The input Primitive with points and normals to deform.", - new PointsPrimitive() - ) - ) -{ - m_positionVarParameter = new StringParameter( - "positionVar", - "The variable name to use as per-point position.", - "P" ); - parameters()->addParameter( m_positionVarParameter ); - - - m_normalVarParameter = new StringParameter( - "normalVar", - "The variable name to use as per-point normal.", - "N" ); - parameters()->addParameter( m_normalVarParameter ); - - m_deformNormalsParameter = new BoolParameter( - "deformNormals", - "Deform the normals of the mesh or just the points.", - false - ); - parameters()->addParameter( m_deformNormalsParameter ); - - IntParameter::PresetsContainer blendPresets; - blendPresets.push_back( IntParameter::Preset( "Linear", Linear ) ); - m_blendParameter = new IntParameter( - "blend", - "Blending algorithm used to deform the mesh.", - Linear, - Linear, - Linear, - blendPresets, - true - ); - parameters()->addParameter( m_blendParameter ); - - m_smoothSkinningDataParameter = new SmoothSkinningDataParameter( - "smoothSkinningData", - "Set the SmoothSkinningData to be used in the deformation", - new SmoothSkinningData() - ); - parameters()->addParameter( m_smoothSkinningDataParameter ); - - m_deformationPoseParameter = new M44fVectorParameter( - "deformationPose", - "Set the deformationPose (a M44fVectorData object) to be used in the deformation", - new M44fVectorData() - ); - parameters()->addParameter( m_deformationPoseParameter ); - - m_refIndicesParameter = new IntVectorParameter( - "referenceIndices", - "Set the reference indices to be used for querying the smooth skinning data in the deformation.", - new IntVectorData() - ); - parameters()->addParameter( m_refIndicesParameter ); - -} - -PointSmoothSkinningOp::~PointSmoothSkinningOp() -{ -} - -StringParameter * PointSmoothSkinningOp::positionVarParameter() -{ - return m_positionVarParameter.get(); -} - -const StringParameter * PointSmoothSkinningOp::positionVarParameter() const -{ - return m_positionVarParameter.get(); -} - -StringParameter * PointSmoothSkinningOp::normalVarParameter() -{ - return m_normalVarParameter.get(); -} - -const StringParameter * PointSmoothSkinningOp::normalVarParameter() const -{ - return m_normalVarParameter.get(); -} - -M44fVectorParameter * PointSmoothSkinningOp::deformationPoseParameter() -{ - return m_deformationPoseParameter.get(); -} - -const M44fVectorParameter * PointSmoothSkinningOp::deformationPoseParameter() const -{ - return m_deformationPoseParameter.get(); -} - -SmoothSkinningDataParameter * PointSmoothSkinningOp::smoothSkinningDataParameter() -{ - return m_smoothSkinningDataParameter.get(); -} - -const SmoothSkinningDataParameter * PointSmoothSkinningOp::smoothSkinningDataParameter() const -{ - return m_smoothSkinningDataParameter.get(); -} - -BoolParameter * PointSmoothSkinningOp::deformNormalsParameter() -{ - return m_deformNormalsParameter.get(); -} - -const BoolParameter * PointSmoothSkinningOp::deformNormalsParameter() const -{ - return m_deformNormalsParameter.get(); -} - -IntParameter * PointSmoothSkinningOp::blendParameter() -{ - return m_blendParameter.get(); -} - -const IntParameter * PointSmoothSkinningOp::blendParameter() const -{ - return m_blendParameter.get(); -} - -IntVectorParameter * PointSmoothSkinningOp::refIndicesParameter() -{ - return m_refIndicesParameter.get(); -} - -const IntVectorParameter * PointSmoothSkinningOp::refIndicesParameter() const -{ - return m_refIndicesParameter.get(); -} - -struct PointSmoothSkinningOp::DeformPositions -{ - public : - - DeformPositions( std::vector &p_data, const std::vector &pointIndexOffsets, const std::vector &pointInfluenceCounts, const std::vector &pointInfluenceIndices, const std::vector &pointInfluenceWeights, const std::vector &skin_data, const std::vector &refId_data ) - : m_pData( p_data ), m_pointIndexOffsets( pointIndexOffsets ), m_pointInfluenceCounts( pointInfluenceCounts ), m_pointInfluenceIndices( pointInfluenceIndices ), m_pointInfluenceWeights( pointInfluenceWeights ), m_skinData(skin_data), m_refIdData(refId_data) - { - } - - void operator()( const tbb::blocked_range &r ) const - { - for( size_t p_it=r.begin(); p_it!=r.end(); ++p_it ) - { - V3f p_new(0,0,0); - - V3f &p_value = m_pData[p_it]; - int p_id; - if( m_refIdData.size() ) - { - // get the actual index to look up in the smooth skinning data - p_id = m_refIdData[p_it]; - } - else - { - p_id = p_it; - } - - int p_influence_count = m_pointInfluenceCounts[p_id]; - int p_index_offset = m_pointIndexOffsets[p_id]; - - for (int p_influence_id = p_index_offset; p_influence_id < (p_index_offset+p_influence_count); - p_influence_id++) - { - int influence_id = m_pointInfluenceIndices[p_influence_id]; - float weight = m_pointInfluenceWeights[p_influence_id]; - p_new += p_value * m_skinData[influence_id] * weight; - } - p_value = p_new; - } - } - - private : - - std::vector &m_pData; - const std::vector &m_pointIndexOffsets; - const std::vector &m_pointInfluenceCounts; - const std::vector &m_pointInfluenceIndices; - const std::vector &m_pointInfluenceWeights; - const std::vector &m_skinData; - const std::vector &m_refIdData; - -}; - -struct PointSmoothSkinningOp::DeformNormals -{ - public : - - DeformNormals( std::vector &n_data, const std::vector &pointIndexOffsets, const std::vector &pointInfluenceCounts, const std::vector &pointInfluenceIndices, const std::vector &pointInfluenceWeights, const std::vector &skin_data, const std::vector &refId_data, std::vector &vertexIndicesData ) - : m_nData( n_data ), m_pointIndexOffsets( pointIndexOffsets ), m_pointInfluenceCounts( pointInfluenceCounts ), m_pointInfluenceIndices( pointInfluenceIndices ), m_pointInfluenceWeights( pointInfluenceWeights ), m_skinData(skin_data), m_refIdData(refId_data), m_vertexIndicesData( vertexIndicesData ) - { - } - - void operator()( const tbb::blocked_range &r ) const - { - for( size_t n_it=r.begin(); n_it!=r.end(); ++n_it ) - { - V3f n_new(0,0,0); - - V3f &n_value = m_nData[n_it]; - V3f n_unw; - - int n_id = n_it; - - if( m_vertexIndicesData.size() ) - { - n_id = m_vertexIndicesData[n_id]; - } - if( m_refIdData.size() ) - { - n_id = m_refIdData[n_id]; - } - - int n_influence_count = m_pointInfluenceCounts[n_id]; - int n_index_offset = m_pointIndexOffsets[n_id]; - - for (int n_influence_id = n_index_offset; n_influence_id < (n_index_offset+n_influence_count); - n_influence_id++) - { - int influence_id = m_pointInfluenceIndices[n_influence_id]; - float weight = m_pointInfluenceWeights[n_influence_id]; - - m_skinData[influence_id].multDirMatrix(n_value,n_unw); - n_new += n_unw * weight; - } - n_value = n_new; - } - } - - private : - - std::vector &m_nData; - const std::vector &m_pointIndexOffsets; - const std::vector &m_pointInfluenceCounts; - const std::vector &m_pointInfluenceIndices; - const std::vector &m_pointInfluenceWeights; - const std::vector &m_skinData; - const std::vector &m_refIdData; - const std::vector &m_vertexIndicesData; - -}; - -void PointSmoothSkinningOp::modify( Object *input, const CompoundObject *operands ) -{ - // get the input parameters - Primitive *pt = static_cast( input ); - - bool deform_n = operands->member( "deformNormals" )->readable(); - Blend blend = static_cast( m_blendParameter->getNumericValue() ); - string position_var = operands->member( "positionVar" )->readable(); - string normal_var = operands->member( "normalVar" )->readable(); - SmoothSkinningDataPtr ssd = smoothSkinningDataParameter()->getTypedValue< SmoothSkinningData >( ); - M44fVectorDataPtr def = runTimeCast(deformationPoseParameter()->getValue( )); - const std::vector &refId_data = operands->member( "referenceIndices" )->readable(); - - // verify position and normal data - if ( pt->variables.count(position_var)==0 ) - { - throw Exception( "Could not find position variable on primitive!" ); - } - - V3fVectorData *p = pt->variableData(position_var); - if ( !p ) - { - throw Exception("Could not get position data from primitive!"); - } - - std::vector &p_data = p->writable(); - int p_size = p_data.size(); - - // Check reference id data. If provided, it must be the same size as P. - int refId_size = refId_data.size(); - if( refId_size && refId_size != p_size ) - { - throw InvalidArgumentException( "Number of reference indices does not match point count on Primitive given to PointSmoothSkinningOp" ); - } - - // verify the SmoothSkinningData - if ( !ssd ) - { - return; - } - - int ssd_p_size = ssd->pointInfluenceCounts()->readable().size(); - - if ( !refId_size && ssd_p_size != p_size ) - { - throw InvalidArgumentException( "Number of points in SmoothSkinningData does not match point count on Primitive given to PointSmoothSkinningOp" ); - } - - // get the deformation pose and check its compatibility with the SmoothSkinningData - const std::vector &def_data = def->readable(); - int def_size = def_data.size(); - - int inf_size = ssd->influencePose()->readable().size(); - - if (def_size != inf_size) - { - throw InvalidArgumentException( "Number of elements in SmoothSkinningData.influencePose does not match number of elements in deformationPose given to PointSmoothSkinningOp" ); - } - - // check if the smooth skinning data has changed since the last time the op was used; - // validating the ssd can be expensive and unnecessary for the case that the ssd is not changing - // so we are storing an internal copy of the ssd as a comparison is much faster than a complete validation - if ( ssd != m_prevSmoothSkinningData ) - { - ssd->validate(); - m_prevSmoothSkinningData = ssd; - } - - // test n data - if ( deform_n ) - { - PrimitiveVariableMap::const_iterator it = pt->variables.find(normal_var); - if ( it != pt->variables.end() ) - { - if( !pt->isPrimitiveVariableValid( it->second ) ) - { - throw Exception("Normal variable on primitive is invalid!"); - } - if (it->second.interpolation == PrimitiveVariable::FaceVarying ) - { - MeshPrimitive *mesh = dynamic_cast( pt ); - if( !mesh ) - { - V3fVectorData *n = pt->variableData(normal_var); - int n_size = n->readable().size(); - if ( p_size != n_size ) - { - throw Exception("Position and normal variables must be the same length!"); - } - } - } - } - else - { - throw Exception( "Could not find normal variable on primitive!" ); - } - } - - // generate skinning matrices - // we are pre-creating these as in the typical use-case the number of influence objects is much lower - // than the number of vertices that are going to be deformed - std::vector skin_data; - skin_data.reserve( inf_size ); - - std::vector::const_iterator ip_it = ssd->influencePose()->readable().begin(); - - for( std::vector::const_iterator dp_it = def_data.begin(); - dp_it!=def_data.end(); ++dp_it ) - { - - M44f mat = (*ip_it) * (*dp_it); - skin_data.push_back( mat ); - ++ip_it; - } - - - // iterate through all the points in the source primitive and deform using the weighted skinning matrices - if ( blend == Linear ) - { - const std::vector &pointIndexOffsets = ssd->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = ssd->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = ssd->pointInfluenceIndices()->readable(); - const std::vector &pointInfluenceWeights = ssd->pointInfluenceWeights()->readable(); - - // deform our P - tbb::task_group_context taskGroupContext( tbb::task_group_context::isolated ); - tbb::parallel_for( - tbb::blocked_range( 0, p_size ), - DeformPositions( p_data, pointIndexOffsets, pointInfluenceCounts, pointInfluenceIndices, pointInfluenceWeights, skin_data, refId_data ), - taskGroupContext - ); - - // deform our N - if ( deform_n ) - { - PrimitiveVariableMap::const_iterator it = pt->variables.find(normal_var); - if ( it != pt->variables.end() ) - { - V3fVectorData *n = pt->variableData(normal_var); - std::vector &n_data = n->writable(); - - std::vector vertexIndicesData; - if (it->second.interpolation == PrimitiveVariable::FaceVarying ) - { - MeshPrimitive *mesh = dynamic_cast( pt ); - if( mesh ) - { - vertexIndicesData = mesh->vertexIds()->readable(); - } - } - - tbb::parallel_for( - tbb::blocked_range( 0, n_data.size() ), - DeformNormals( - n_data, - pointIndexOffsets, - pointInfluenceCounts, - pointInfluenceIndices, - pointInfluenceWeights, - skin_data, - refId_data, - vertexIndicesData - ), - taskGroupContext - ); - } - } - } - else - { - // this should never happen - assert(0); - } - -} diff --git a/src/IECoreScene/RemoveSmoothSkinningInfluencesOp.cpp b/src/IECoreScene/RemoveSmoothSkinningInfluencesOp.cpp deleted file mode 100644 index 5841159a2b..0000000000 --- a/src/IECoreScene/RemoveSmoothSkinningInfluencesOp.cpp +++ /dev/null @@ -1,224 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/RemoveSmoothSkinningInfluencesOp.h" - -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( RemoveSmoothSkinningInfluencesOp ); - -RemoveSmoothSkinningInfluencesOp::RemoveSmoothSkinningInfluencesOp() - : ModifyOp( - "The RemoveSmoothSkinningInfluencesOp removes influences from the SmoothSkinningData, regardless of existing weights.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - IntParameter::PresetsContainer modePresets; - modePresets.push_back( IntParameter::Preset( "Named", RemoveSmoothSkinningInfluencesOp::Named ) ); - modePresets.push_back( IntParameter::Preset( "Indexed", RemoveSmoothSkinningInfluencesOp::Indexed ) ); - modePresets.push_back( IntParameter::Preset( "Weightless", RemoveSmoothSkinningInfluencesOp::Weightless ) ); - - m_modeParameter = new IntParameter( - "mode", - "The mode of influence removal. Options are to remove by name, index, or to remove influences with no weights", - RemoveSmoothSkinningInfluencesOp::Named, - RemoveSmoothSkinningInfluencesOp::Named, - RemoveSmoothSkinningInfluencesOp::Weightless, - modePresets, - true - ); - - m_influenceNamesParameter = new StringVectorParameter( - "influenceNames", - "Names of the influences to remove. This parameter is only used in Named mode.", - new StringVectorData - ); - - m_indicesParameter = new IntVectorParameter( - "indices", - "Indices of the influences to remove. This parameter is only used in Indexed mode.", - new IntVectorData - ); - - parameters()->addParameter( m_modeParameter ); - parameters()->addParameter( m_influenceNamesParameter ); - parameters()->addParameter( m_indicesParameter ); -} - -RemoveSmoothSkinningInfluencesOp::~RemoveSmoothSkinningInfluencesOp() -{ -} - -void RemoveSmoothSkinningInfluencesOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &influenceNames = skinningData->influenceNames()->readable(); - const std::vector &influencePoseData = skinningData->influencePose()->readable(); - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - const std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->readable(); - - // gather the influence indices - std::vector indicesToRemove; - const unsigned numInfluences = influenceNames.size(); - const int mode = m_modeParameter->getNumericValue(); - if ( mode == RemoveSmoothSkinningInfluencesOp::Named ) - { - const std::vector &removeNames = m_influenceNamesParameter->getTypedValue(); - for ( unsigned i=0; i < removeNames.size(); i++ ) - { - std::string name = removeNames[i]; - const std::vector::const_iterator location = find( influenceNames.begin(), influenceNames.end(), name ); - if ( location == influenceNames.end() ) - { - throw IECore::Exception( ( boost::format( "RemoveSmoothSkinningInfluencesOp: \"%d\" is not a valid influence name" ) % name ).str() ); - } - - indicesToRemove.push_back( location - influenceNames.begin() ); - } - } - else if ( mode == RemoveSmoothSkinningInfluencesOp::Indexed ) - { - indicesToRemove = m_indicesParameter->getTypedValue(); - for ( unsigned i=0; i < indicesToRemove.size(); i++ ) - { - if ( indicesToRemove[i] > (int)numInfluences - 1 ) - { - throw IECore::Exception( ( boost::format( "RemoveSmoothSkinningInfluencesOp: \"%d\" is not a valid index" ) % indicesToRemove[i] ).str() ); - } - } - } - else if ( mode == RemoveSmoothSkinningInfluencesOp::Weightless ) - { - std::set indicesToKeep; - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - - if ( pointInfluenceWeights[current] > 0.0f ) - { - indicesToKeep.insert( pointInfluenceIndices[current] ); - } - } - - if ( indicesToKeep.size() == numInfluences ) - { - break; - } - } - - for ( unsigned i=0; i < numInfluences; i++ ) - { - if ( indicesToKeep.find( i ) == indicesToKeep.end() ) - { - indicesToRemove.push_back( i ); - } - } - } - else - { - throw IECore::Exception( ( boost::format( "RemoveSmoothSkinningInfluencesOp: \"%d\" is not a recognized mode" ) % mode ).str() ); - } - - std::vector indexMap; - std::vector keepNames; - std::vector keepPoseData; - std::vector newOffsets; - std::vector newCounts; - std::vector newIndices; - std::vector newWeights; - - // calculate the map between old and new influence indices - for ( int i=0; i < (int)numInfluences; i++ ) - { - if ( find( indicesToRemove.begin(), indicesToRemove.end(), i ) == indicesToRemove.end() ) - { - indexMap.push_back( keepNames.size() ); - keepNames.push_back( influenceNames[i] ); - keepPoseData.push_back( influencePoseData[i] ); - } - else - { - indexMap.push_back( -1 ); - } - } - - // adjust the data vectors - int offset = 0; - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - int count = 0; - - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - - if ( indexMap[ pointInfluenceIndices[current] ] != -1 ) - { - newIndices.push_back( indexMap[ pointInfluenceIndices[current] ] ); - newWeights.push_back( pointInfluenceWeights[current] ); - count++; - } - } - - newOffsets.push_back( offset ); - newCounts.push_back( count ); - offset += count; - } - - // replace the vectors on the SmoothSkinningData - skinningData->influenceNames()->writable().swap( keepNames ); - skinningData->influencePose()->writable().swap( keepPoseData ); - skinningData->pointIndexOffsets()->writable().swap( newOffsets ); - skinningData->pointInfluenceCounts()->writable().swap( newCounts ); - skinningData->pointInfluenceIndices()->writable().swap( newIndices ); - skinningData->pointInfluenceWeights()->writable().swap( newWeights ); -} diff --git a/src/IECoreScene/ReorderSmoothSkinningInfluencesOp.cpp b/src/IECoreScene/ReorderSmoothSkinningInfluencesOp.cpp deleted file mode 100644 index 44b5ff782e..0000000000 --- a/src/IECoreScene/ReorderSmoothSkinningInfluencesOp.cpp +++ /dev/null @@ -1,119 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/ReorderSmoothSkinningInfluencesOp.h" - -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( ReorderSmoothSkinningInfluencesOp ); - -ReorderSmoothSkinningInfluencesOp::ReorderSmoothSkinningInfluencesOp() - : ModifyOp( - "The ReorderSmoothSkinningInfluencesOp changes the order of the influences in SmoothSkinningData.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_reorderedInfluencesParameter = new StringVectorParameter( - "reorderedInfluenceNames", - "The influenceNames in a new order", - new StringVectorData - ); - - parameters()->addParameter( m_reorderedInfluencesParameter ); -} - -ReorderSmoothSkinningInfluencesOp::~ReorderSmoothSkinningInfluencesOp() -{ -} - -void ReorderSmoothSkinningInfluencesOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::vector &newOrder = m_reorderedInfluencesParameter->getTypedValue(); - const std::vector &originalOrder = skinningData->influenceNames()->readable(); - const std::vector &originalPoseData = skinningData->influencePose()->readable(); - - std::vector orderMap( originalOrder.size() ); - std::vector finalOrder; - std::vector finalPoseData; - std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->writable(); - - if ( newOrder.size() != originalOrder.size() ) - { - throw IECore::Exception( "ReorderSmoothSkinningInfluencesOp: reorderedInfluenceNames and input.influenceNames must contain the same names" ); - } - - // create the mapping between originalOrder and newOrder - for ( unsigned i=0; i < newOrder.size(); i++ ) - { - std::string name = newOrder[i]; - - const std::vector::const_iterator location = find( originalOrder.begin(), originalOrder.end(), name ); - if ( location == originalOrder.end() ) - { - throw IECore::Exception( ( boost::format( "ReorderSmoothSkinningInfluencesOp: \"%s\" is not an original influenceName" ) % name ).str() ); - } - - unsigned originalIndex = location - originalOrder.begin(); - orderMap[originalIndex] = i; - finalOrder.push_back( name ); - finalPoseData.push_back( originalPoseData[originalIndex] ); - } - - // update the pointInfluenceIndices - for ( unsigned i=0; i < pointInfluenceIndices.size(); i++ ) - { - int newIndex = orderMap[ pointInfluenceIndices[i] ]; - pointInfluenceIndices[i] = newIndex; - - } - - // swap the names and poses - skinningData->influenceNames()->writable().swap( finalOrder ); - skinningData->influencePose()->writable().swap( finalPoseData ); -} diff --git a/src/IECoreScene/SmoothSkinningData.cpp b/src/IECoreScene/SmoothSkinningData.cpp deleted file mode 100644 index 12aa3ef4ef..0000000000 --- a/src/IECoreScene/SmoothSkinningData.cpp +++ /dev/null @@ -1,369 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/SmoothSkinningData.h" - -#include "IECore/VectorTypedData.h" - -#include "boost/format.hpp" - -using namespace IECore; -using namespace IECoreScene; -using namespace boost; - -static IndexedIO::EntryID g_influenceNamesEntry("influenceNames"); -static IndexedIO::EntryID g_influencePoseEntry("influencePose"); -static IndexedIO::EntryID g_pointIndexOffsetsEntry("pointIndexOffsets"); -static IndexedIO::EntryID g_pointInfluenceCountsEntry("pointInfluenceCounts"); -static IndexedIO::EntryID g_pointInfluenceIndicesEntry("pointInfluenceIndices"); -static IndexedIO::EntryID g_pointInfluenceWeightsEntry("pointInfluenceWeights"); - -const unsigned int SmoothSkinningData::m_ioVersion = 1; - -IE_CORE_DEFINEOBJECTTYPEDESCRIPTION(SmoothSkinningData); - -SmoothSkinningData::SmoothSkinningData() : - m_influenceNames( new StringVectorData ), - m_influencePose( new M44fVectorData ), - m_pointIndexOffsets( new IntVectorData ), - m_pointInfluenceCounts( new IntVectorData ), - m_pointInfluenceIndices( new IntVectorData ), - m_pointInfluenceWeights( new FloatVectorData ) -{ -} - -SmoothSkinningData::SmoothSkinningData( ConstStringVectorDataPtr influenceNames, - ConstM44fVectorDataPtr influencePose, - ConstIntVectorDataPtr pointIndexOffsets, - ConstIntVectorDataPtr pointInfluenceCounts, - ConstIntVectorDataPtr pointInfluenceIndices, - ConstFloatVectorDataPtr pointInfluenceWeights) -{ - assert( influenceNames ); - assert( influencePose ); - assert( pointIndexOffsets ); - assert( pointInfluenceCounts ); - assert( pointInfluenceIndices ); - assert( pointInfluenceWeights ); - - m_influenceNames = influenceNames->copy(); - m_influencePose = influencePose->copy(); - m_pointIndexOffsets = pointIndexOffsets->copy(); - m_pointInfluenceCounts = pointInfluenceCounts->copy(); - m_pointInfluenceIndices = pointInfluenceIndices->copy(); - m_pointInfluenceWeights = pointInfluenceWeights->copy(); -} - -SmoothSkinningData::~SmoothSkinningData() -{ -} - -const StringVectorData *SmoothSkinningData::influenceNames() const -{ - return m_influenceNames.get(); -} - -StringVectorData *SmoothSkinningData::influenceNames() -{ - return m_influenceNames.get(); -} - -const M44fVectorData *SmoothSkinningData::influencePose() const -{ - return m_influencePose.get(); -} - -M44fVectorData *SmoothSkinningData::influencePose() -{ - return m_influencePose.get(); -} - -const IntVectorData *SmoothSkinningData::pointIndexOffsets() const -{ - return m_pointIndexOffsets.get(); -} - -IntVectorData *SmoothSkinningData::pointIndexOffsets() -{ - return m_pointIndexOffsets.get(); -} - -const IntVectorData *SmoothSkinningData::pointInfluenceCounts() const -{ - return m_pointInfluenceCounts.get(); -} - -IntVectorData *SmoothSkinningData::pointInfluenceCounts() -{ - return m_pointInfluenceCounts.get(); -} - -const IntVectorData *SmoothSkinningData::pointInfluenceIndices() const -{ - return m_pointInfluenceIndices.get(); -} - -IntVectorData *SmoothSkinningData::pointInfluenceIndices() -{ - return m_pointInfluenceIndices.get(); -} - -const FloatVectorData *SmoothSkinningData::pointInfluenceWeights() const -{ - return m_pointInfluenceWeights.get(); -} - -FloatVectorData *SmoothSkinningData::pointInfluenceWeights() -{ - return m_pointInfluenceWeights.get(); -} - -void SmoothSkinningData::validateSizes() const -{ - int cin = m_influenceNames->readable().size(); - int cip = m_influencePose->readable().size(); - - // check vector sizes - if (cin != cip) - { - std::string error = str( format( "SmoothSkinningData: Number of influenceNames '%e' does not match number of influencePose '%e'!" ) % cin % cip); - throw Exception( error ); - } - - int cpio = m_pointIndexOffsets->readable().size(); - int cpic = m_pointInfluenceCounts->readable().size(); - - if (cpio != cpic) - { - std::string error = str( format( "SmoothSkinningData: Number of pointIndexOffsets '%e' does not match number of pointInfluenceCounts '%e'!" ) % cpio % cpic); - throw Exception( error ); - } - - int cpii = m_pointInfluenceIndices->readable().size(); - int cpiw = m_pointInfluenceWeights->readable().size(); - - if (cpii != cpiw) - { - std::string error = str( format( "SmoothSkinningData: Number of pointInfluenceIndices '%e' does not match number of pointInfluenceWeights '%e'!" ) % cpii % cpiw); - throw Exception( error ); - } -} - -void SmoothSkinningData::validateCounts() const -{ - // check for wrong counts in m_pointInfluenceCounts - int sum =0; - for( std::vector::const_iterator it = m_pointInfluenceCounts->readable().begin(); - it!=m_pointInfluenceCounts->readable().end(); ++it ) - { - sum += (*it); - } - - int cpii = m_pointInfluenceIndices->readable().size(); - if ( sum != cpii ) - { - std::string error = str( format( "SmoothSkinningData: Sum of all pointInfluenceCounts '%e' does not match size of pointInfluenceIndices and pointInfluenceWeightsmatch number of pointInfluenceWeights '%e'!" ) % sum % cpii); - throw Exception( error ); - } -} - -void SmoothSkinningData::validateIds() const -{ - int cpii = m_pointInfluenceIndices->readable().size(); - int cin = m_influenceNames->readable().size(); - // check for invalid ids in m_pointIndexOffset - for( std::vector::const_iterator it = m_pointIndexOffsets->readable().begin(); - it!=m_pointIndexOffsets->readable().end(); ++it ) - { - int o = (*it); - if ( ( o < 0 ) || ( o > (cpii-1) ) ) - { - int id = it - m_pointIndexOffsets->readable().begin(); - std::string error = str( format( "SmoothSkinningData: pointIndexOffset[%e] with value '%e' is not pointing to valid index in pointInfluenceWeights vector range [ 0, %e ]!" ) % id % o % (cpii-1) ); - throw Exception( error ); - } - } - - // check for invalid ids in_pointInfluenceIndices - for( std::vector::const_iterator it = m_pointInfluenceIndices->readable().begin(); - it!=m_pointInfluenceIndices->readable().end(); ++it ) - { - int o = (*it); - if ( ( o < 0 ) || ( o > (cin-1) ) ) - { - int id = it - m_pointInfluenceIndices->readable().begin(); - std::string error = str( format( "SmoothSkinningData: pointInfluenceIndices[%e] with value '%e' is not pointing to valid index in influenceNames vector range [ 0, %e ]!" ) % id % o % (cin-1) ); - throw Exception( error ); - } - } -} - -void SmoothSkinningData::validateOffsets() const -{ - // check for mismatches of m_pointInfluenceCounts and m_pointIndexOffsets - std::vector::const_iterator pio_it = m_pointIndexOffsets->readable().begin(); - int sum = 0; - for( std::vector::const_iterator pic_it = m_pointInfluenceCounts->readable().begin(); - pic_it!=m_pointInfluenceCounts->readable().end(); ++pic_it ) - { - int pic = (*pic_it); - int pio = (*pio_it); - - - if (sum != pio) - { - int id = pio_it - m_pointIndexOffsets->readable().begin(); - std::string error = str( format( "SmoothSkinningData: pointInfluenceOffsets[%e] is pointing to index '%e', but sum of all pointInfluenceCounts up to this id is '%e'!" ) % id % pio % sum ); - throw Exception( error ); - } - sum += pic; - ++pio_it; - } -} - -void SmoothSkinningData::validate() const -{ - validateSizes(); - validateIds(); - validateCounts(); - validateOffsets(); -} - -void SmoothSkinningData::copyFrom( const IECore::Object *other, IECore::Object::CopyContext *context ) -{ - Data::copyFrom( other, context ); - const SmoothSkinningData *tOther = static_cast( other ); - m_influenceNames = tOther->m_influenceNames->copy(); - m_influencePose = tOther->m_influencePose->copy(); - m_pointIndexOffsets = tOther->m_pointIndexOffsets->copy(); - m_pointInfluenceCounts = tOther->m_pointInfluenceCounts->copy(); - m_pointInfluenceIndices = tOther->m_pointInfluenceIndices->copy(); - m_pointInfluenceWeights = tOther->m_pointInfluenceWeights->copy(); -} - -void SmoothSkinningData::save( IECore::Object::SaveContext *context ) const -{ - Data::save(context); - IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); - context->save( m_influenceNames.get(), container.get(), g_influenceNamesEntry ); - context->save( m_influencePose.get(), container.get(), g_influencePoseEntry ); - context->save( m_pointIndexOffsets.get(), container.get(), g_pointIndexOffsetsEntry ); - context->save( m_pointInfluenceCounts.get(), container.get(), g_pointInfluenceCountsEntry ); - context->save( m_pointInfluenceIndices.get(), container.get(), g_pointInfluenceIndicesEntry ); - context->save( m_pointInfluenceWeights.get(), container.get(), g_pointInfluenceWeightsEntry ); -} - -void SmoothSkinningData::load( IECore::Object::LoadContextPtr context ) -{ - Data::load(context); - unsigned int v = m_ioVersion; - - ConstIndexedIOPtr container = context->container( staticTypeName(), v ); - - m_influenceNames = context->load( container.get(), g_influenceNamesEntry ); - m_influencePose = context->load( container.get(), g_influencePoseEntry ); - m_pointIndexOffsets = context->load( container.get(), g_pointIndexOffsetsEntry ); - m_pointInfluenceCounts = context->load( container.get(), g_pointInfluenceCountsEntry ); - m_pointInfluenceIndices = context->load( container.get(), g_pointInfluenceIndicesEntry ); - m_pointInfluenceWeights = context->load( container.get(), g_pointInfluenceWeightsEntry ); - -} - -bool SmoothSkinningData::isEqualTo( const IECore::Object *other ) const -{ - - if( !Data::isEqualTo( other ) ) - { - return false; - } - - const SmoothSkinningData *tOther = static_cast( other ); - - if( !m_influenceNames->isEqualTo( tOther->m_influenceNames.get() ) ) - { - return false; - } - - if( !m_influencePose->isEqualTo( tOther->m_influencePose.get() ) ) - { - return false; - } - - if( !m_influencePose->isEqualTo( tOther->m_influencePose.get() ) ) - { - return false; - } - - if( !m_pointInfluenceCounts->isEqualTo( tOther->m_pointInfluenceCounts.get() ) ) - { - return false; - } - - if( !m_pointInfluenceIndices->isEqualTo( tOther->m_pointInfluenceIndices.get() ) ) - { - return false; - } - - if( !m_pointInfluenceWeights->isEqualTo( tOther->m_pointInfluenceWeights.get() ) ) - { - return false; - } - - return true; -} - -void SmoothSkinningData::memoryUsage( Object::MemoryAccumulator &a ) const -{ - Data::memoryUsage( a ); - a.accumulate( m_influenceNames.get() ); - a.accumulate( m_influencePose.get() ); - a.accumulate( m_pointIndexOffsets.get() ); - a.accumulate( m_pointInfluenceCounts.get() ); - a.accumulate( m_pointInfluenceIndices.get() ); - a.accumulate( m_pointInfluenceWeights.get() ); -} - -void SmoothSkinningData::hash( MurmurHash &h ) const -{ - Data::hash( h ); - m_influenceNames->hash( h ); - m_influencePose->hash( h ); - m_pointIndexOffsets->hash( h ); - m_pointInfluenceCounts->hash( h ); - m_pointInfluenceIndices->hash( h ); - m_pointInfluenceWeights->hash( h ); -} diff --git a/src/IECoreScene/SmoothSmoothSkinningWeightsOp.cpp b/src/IECoreScene/SmoothSmoothSkinningWeightsOp.cpp deleted file mode 100644 index 986516b3ce..0000000000 --- a/src/IECoreScene/SmoothSmoothSkinningWeightsOp.cpp +++ /dev/null @@ -1,289 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/SmoothSmoothSkinningWeightsOp.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" -#include "IECoreScene/NormalizeSmoothSkinningWeightsOp.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/Interpolator.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( SmoothSmoothSkinningWeightsOp ); - -SmoothSmoothSkinningWeightsOp::SmoothSmoothSkinningWeightsOp() - : ModifyOp( - "The SmoothSmoothSkinningWeightsOp smooths the weights of SmoothSkinningData using the average weights from connected vertices", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_meshParameter = new MeshPrimitiveParameter( - "mesh", - "The mesh primitive corresponding to the input SmoothSkinningData", - new MeshPrimitive - ); - - m_vertexIdsParameter = new FrameListParameter( - "vertexIndices", - "The indices of the vertices to smooth. All vertices will be smoothed if this parameter is empty", - "" - ); - - m_smoothingRatioParameter = new FloatParameter( - "smoothingRatio", - "Controls the level of smoothing. Higher values give greater weight to neighbour vertices", - 0.5, - 0.0, - 1.0 - ); - - m_iterationsParameter = new IntParameter( - "iterations", - "The number of iterations to perform the smoothing operation", - 1, - 1 - ); - - m_useLocksParameter = new BoolParameter( - "applyLocks", - "Whether or not influenceLocks should be applied", - true - ); - - m_influenceLocksParameter = new BoolVectorParameter( - "influenceLocks", - "A per-influence list of lock values", - new BoolVectorData - ); - - parameters()->addParameter( m_meshParameter ); - parameters()->addParameter( m_vertexIdsParameter ); - parameters()->addParameter( m_smoothingRatioParameter ); - parameters()->addParameter( m_iterationsParameter ); - parameters()->addParameter( m_useLocksParameter ); - parameters()->addParameter( m_influenceLocksParameter ); -} - -SmoothSmoothSkinningWeightsOp::~SmoothSmoothSkinningWeightsOp() -{ -} - -void SmoothSmoothSkinningWeightsOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - // decompress - DecompressSmoothSkinningDataOp decompressionOp; - decompressionOp.inputParameter()->setValidatedValue( skinningData ); - decompressionOp.copyParameter()->setTypedValue( false ); - decompressionOp.operate(); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - int numSsdVerts = pointIndexOffsets.size(); - - std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - - const MeshPrimitive *mesh = runTimeCast( m_meshParameter->getValidatedValue() ); - if ( !mesh ) - { - throw IECore::Exception( "SmoothSmoothSkinningWeightsOp: The given mesh is not valid" ); - } - int numMeshVerts = mesh->variableSize( PrimitiveVariable::Vertex ); - const std::vector &meshVertexIds = mesh->vertexIds()->readable(); - - // make sure the mesh matches the skinning data - if ( numMeshVerts != numSsdVerts ) - { - throw IECore::Exception( "SmoothSmoothSkinningWeightsOp: The input SmoothSkinningData and mesh have a different number of vertices" ); - } - - bool useLocks = m_useLocksParameter->getTypedValue(); - std::vector &locks = m_influenceLocksParameter->getTypedValue(); - - // make sure there is one lock per influence - if ( useLocks && ( locks.size() != skinningData->influenceNames()->readable().size() ) ) - { - throw IECore::Exception( "SmoothSmoothSkinningWeightsOp: There must be exactly one lock per influence" ); - } - - if ( !useLocks ) - { - locks.clear(); - locks.resize( skinningData->influenceNames()->readable().size(), false ); - } - - std::vector vertexIds; - m_vertexIdsParameter->getFrameListValue()->asList( vertexIds ); - - // make sure all vertex ids are valid - for ( unsigned i=0; i < vertexIds.size(); i++ ) - { - if ( vertexIds[i] > numSsdVerts ) - { - throw IECore::Exception( ( boost::format( "SmoothSmoothSkinningWeightsOp: VertexId \"%d\" is outside the range of the SmoothSkinningData and mesh" ) % vertexIds[i] ).str() ); - } - } - - // an empty vertexId list means we smooth all vertices - if ( vertexIds.size() == 0 ) - { - for ( int i=0; i < numSsdVerts; i++ ) - { - vertexIds.push_back( i ); - } - } - - // add the mesh vertices to the neighbourhood graph - /// \todo: consider moving this mesh connectivity graphing to the MeshPrimitive - Graph meshGraph; - for ( int i=0; i < numMeshVerts; i++ ) - { - boost::add_vertex( meshGraph ); - } - - // add the mesh edges to the neighbourhood graph - int v = 0, v1, v2; - const std::vector &verticesPerFace = mesh->verticesPerFace()->readable(); - unsigned numFaces = verticesPerFace.size(); - for ( unsigned f=0; f < numFaces; f++ ) - { - for ( int fv=0; fv < verticesPerFace[f] - 1; fv++ ) - { - v1 = meshVertexIds[v+fv]; - v2 = meshVertexIds[v+fv+1]; - - Vertex source = boost::vertex( v1, meshGraph ); - Vertex target = boost::vertex( v2, meshGraph ); - if ( !boost::edge( source, target, meshGraph ).second ) - { - boost::add_edge( source, target, meshGraph ); - } - } - - v1 = meshVertexIds[v + verticesPerFace[f] - 1]; - v2 = meshVertexIds[v]; - Vertex source = boost::vertex( v1, meshGraph ); - Vertex target = boost::vertex( v2, meshGraph ); - if ( !boost::edge( source, target, meshGraph ).second ) - { - boost::add_edge( source, target, meshGraph ); - } - - v += verticesPerFace[f]; - } - - // get the property map that relates each Graph Vertex to a vertexId - VertexIdMap vertexIdMap = boost::get( boost::vertex_index, meshGraph ); - - std::vector smoothInfluenceWeights( skinningData->pointInfluenceWeights()->readable().size(), 0.0f ); - LinearInterpolator lerp; - float smoothingRatio = m_smoothingRatioParameter->getNumericValue(); - int numIterations = m_iterationsParameter->getNumericValue(); - - NormalizeSmoothSkinningWeightsOp normalizeOp; - normalizeOp.copyParameter()->setTypedValue( false ); - normalizeOp.parameters()->setParameterValue( "applyLocks", m_useLocksParameter->getValue() ); - normalizeOp.parameters()->setParameterValue( "influenceLocks", m_influenceLocksParameter->getValue() ); - - // iterate - for ( int iteration=0; iteration < numIterations; iteration++ ) - { - // smooth the weights - for ( unsigned i=0; i < vertexIds.size(); i++ ) - { - int currentVertId = vertexIds[i]; - Vertex currentVert = boost::vertex( currentVertId, meshGraph ); - NeighbourIteratorRange neighbourhood = boost::adjacent_vertices( currentVert, meshGraph ); - float numNeighbours = boost::out_degree( currentVert, meshGraph ); - - for ( int j=0; j < pointInfluenceCounts[currentVertId]; j++ ) - { - int current = pointIndexOffsets[currentVertId] + j; - - // calculate the average neighbour weight - float totalNeighbourWeight = 0.0f; - for( NeighbourIterator nIt = neighbourhood.first; nIt != neighbourhood.second; nIt++ ) - { - int neighbourId = vertexIdMap[*nIt]; - float currentNeighbourWeight = pointInfluenceWeights[ pointIndexOffsets[neighbourId] + j ]; - totalNeighbourWeight += currentNeighbourWeight; - } - float averageNeighbourWeight = totalNeighbourWeight / numNeighbours; - - lerp( pointInfluenceWeights[current], averageNeighbourWeight, smoothingRatio, smoothInfluenceWeights[current] ); - } - } - - // apply the per-influence locks - for ( unsigned i=0; i < vertexIds.size(); i++ ) - { - int currentVertId = vertexIds[i]; - - for ( int j=0; j < pointInfluenceCounts[currentVertId]; j++ ) - { - int current = pointIndexOffsets[currentVertId] + j; - - if ( !locks[ pointInfluenceIndices[current] ] ) - { - pointInfluenceWeights[current] = smoothInfluenceWeights[current]; - } - } - } - - // normalize - normalizeOp.inputParameter()->setValidatedValue( skinningData ); - normalizeOp.operate(); - } - - // re-compress - CompressSmoothSkinningDataOp compressionOp; - compressionOp.inputParameter()->setValidatedValue( skinningData ); - compressionOp.copyParameter()->setTypedValue( false ); - compressionOp.operate(); -} diff --git a/src/IECoreScene/TransferSmoothSkinningWeightsOp.cpp b/src/IECoreScene/TransferSmoothSkinningWeightsOp.cpp deleted file mode 100644 index 426afd694f..0000000000 --- a/src/IECoreScene/TransferSmoothSkinningWeightsOp.cpp +++ /dev/null @@ -1,165 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECoreScene/TransferSmoothSkinningWeightsOp.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" -#include "IECoreScene/SmoothSkinningData.h" -#include "IECoreScene/TypedObjectParameter.h" - -#include "IECore/CompoundObject.h" -#include "IECore/CompoundParameter.h" -#include "IECore/SimpleTypedData.h" - -#include -#include - -using namespace IECore; -using namespace IECoreScene; - -IE_CORE_DEFINERUNTIMETYPED( TransferSmoothSkinningWeightsOp ); - -TransferSmoothSkinningWeightsOp::TransferSmoothSkinningWeightsOp() - : ModifyOp( - "The TransferSmoothSkinningWeightsOp transfers all source influence weights onto a target.", - new SmoothSkinningDataParameter( "result", "The result", new SmoothSkinningData ), - new SmoothSkinningDataParameter( "input", "The SmoothSkinningData to modify", new SmoothSkinningData ) - ) -{ - m_targetInfluenceNameParameter = new StringParameter( - "targetInfluenceName", - "The target influence name", - new StringData - ); - - m_sourceInfluenceNamesParameter = new StringVectorParameter( - "sourceInfluenceNames", - "The source influence names", - new StringVectorData - ); - parameters()->addParameter( m_targetInfluenceNameParameter ); - parameters()->addParameter( m_sourceInfluenceNamesParameter ); -} - -TransferSmoothSkinningWeightsOp::~TransferSmoothSkinningWeightsOp() -{ -} - -void TransferSmoothSkinningWeightsOp::modify( Object * object, const CompoundObject * operands ) -{ - SmoothSkinningData *skinningData = static_cast( object ); - assert( skinningData ); - - const std::string target = m_targetInfluenceNameParameter->getTypedValue(); - const std::vector &sources = m_sourceInfluenceNamesParameter->getTypedValue(); - if ( !sources.size() ) - { - throw IECore::Exception( "TransferSmoothSkinningWeightsOp: you need to specify source influences" ); - } - - const std::vector &influenceNames = skinningData->influenceNames()->readable(); - - const std::vector::const_iterator foundSame = find( sources.begin(), sources.end(), target ); - if ( foundSame != sources.end() ) - { - throw IECore::Exception( ( boost::format( "TransferSmoothSkinningWeightsOp: \"%s\" cannot be both source and target" ) % target ).str() ); - } - - const std::vector::const_iterator location = find( influenceNames.begin(), influenceNames.end(), target ); - if ( location == influenceNames.end() ) - { - throw IECore::Exception( ( boost::format( "TransferSmoothSkinningWeightsOp: \"%s\" is not a valid influence name" ) % target ).str() ); - } - int targetIndex = location - influenceNames.begin(); - std::vector sourceIndices; - - for ( unsigned i=0; i < sources.size(); i++ ) - { - std::string name = sources[i]; - - const std::vector::const_iterator found = find( influenceNames.begin(), influenceNames.end(), name ); - if ( found == influenceNames.end() ) - { - throw IECore::Exception( ( boost::format( "TransferSmoothSkinningWeightsOp: \"%s\" is not a valid influenceName" ) % name ).str() ); - } - sourceIndices.push_back( found - influenceNames.begin() ); - } - - // decompress skinning data - DecompressSmoothSkinningDataOpPtr decompressionOp = new DecompressSmoothSkinningDataOp; - decompressionOp->inputParameter()->setValidatedValue( skinningData ); - decompressionOp->copyParameter()->setTypedValue( false ); - decompressionOp->operate(); - - const std::vector &pointIndexOffsets = skinningData->pointIndexOffsets()->readable(); - const std::vector &pointInfluenceCounts = skinningData->pointInfluenceCounts()->readable(); - const std::vector &pointInfluenceIndices = skinningData->pointInfluenceIndices()->readable(); - std::vector &pointInfluenceWeights = skinningData->pointInfluenceWeights()->writable(); - - for ( unsigned i=0; i < pointIndexOffsets.size(); i++ ) - { - float targetWeight = 0.0; - int targetCurrentIndex = 0; - - for ( int j=0; j < pointInfluenceCounts[i]; j++ ) - { - int current = pointIndexOffsets[i] + j; - int index = pointInfluenceIndices[current]; - float weight = pointInfluenceWeights[current]; - - if( index == targetIndex ) - { - targetWeight += weight; - targetCurrentIndex = current; - } - else - { - const std::vector::const_iterator found = find( sourceIndices.begin(), sourceIndices.end(), index ); - if ( found != sourceIndices.end() ) - { - targetWeight += weight; - pointInfluenceWeights[ current ] = 0.0; - } - } - } - pointInfluenceWeights[ targetCurrentIndex ] = targetWeight; - } - - // re-compress - CompressSmoothSkinningDataOpPtr compressionOp = new CompressSmoothSkinningDataOp; - compressionOp->inputParameter()->setValidatedValue( skinningData ); - compressionOp->copyParameter()->setTypedValue( false ); - compressionOp->operate(); -} diff --git a/src/IECoreScene/TypedObjectParameter.cpp b/src/IECoreScene/TypedObjectParameter.cpp index aacb13edfd..14635bb2e5 100644 --- a/src/IECoreScene/TypedObjectParameter.cpp +++ b/src/IECoreScene/TypedObjectParameter.cpp @@ -36,7 +36,6 @@ #include "IECoreScene/Renderable.h" #include "IECoreScene/Shader.h" -#include "IECoreScene/SmoothSkinningData.h" #include "IECoreScene/VisibleRenderable.h" #include "IECore/TypedObjectParameter.inl" @@ -47,11 +46,9 @@ namespace IECore IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( IECoreScene::RenderableParameter, IECoreScene::RenderableParameterTypeId ); IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( IECoreScene::ShaderParameter, IECoreScene::ShaderParameterTypeId ); IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( IECoreScene::VisibleRenderableParameter, IECoreScene::VisibleRenderableParameterTypeId ); -IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( IECoreScene::SmoothSkinningDataParameter, IECoreScene::SmoothSkinningDataParameterTypeId ); template class TypedObjectParameter; template class TypedObjectParameter; template class TypedObjectParameter; -template class TypedObjectParameter; } diff --git a/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.cpp b/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.cpp deleted file mode 100644 index 9e6aa0ecca..0000000000 --- a/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "AddSmoothSkinningInfluencesOpBinding.h" - -#include "IECoreScene/AddSmoothSkinningInfluencesOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindAddSmoothSkinningInfluencesOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.h b/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.h deleted file mode 100644 index 03c41e25d6..0000000000 --- a/src/IECoreScene/bindings/AddSmoothSkinningInfluencesOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_ADDSMOOTHSKINNINGINFLUENCESOPBINDING_H -#define IECORESCENEMODULE_ADDSMOOTHSKINNINGINFLUENCESOPBINDING_H - -namespace IECoreSceneModule -{ -void bindAddSmoothSkinningInfluencesOp(); -} - -#endif // IECORESCENEMODULE_ADDSMOOTHSKINNINGINFLUENCESOPBINDING_H diff --git a/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.cpp b/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.cpp deleted file mode 100644 index bce0c0f561..0000000000 --- a/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.cpp +++ /dev/null @@ -1,58 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "CompressSmoothSkinningDataOpBinding.h" - -#include "IECoreScene/CompressSmoothSkinningDataOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECore; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindCompressSmoothSkinningDataOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.h b/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.h deleted file mode 100644 index 1c7af8eb81..0000000000 --- a/src/IECoreScene/bindings/CompressSmoothSkinningDataOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_COMPRESSSMOOTHSKINNINGDATAOPBINDING_H -#define IECORESCENEMODULE_COMPRESSSMOOTHSKINNINGDATAOPBINDING_H - -namespace IECoreSceneModule -{ -void bindCompressSmoothSkinningDataOp(); -} - -#endif // IECORESCENEMODULE_COMPRESSSMOOTHSKINNINGDATAOPBINDING_H diff --git a/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.cpp b/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.cpp deleted file mode 100644 index 798ec90130..0000000000 --- a/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010-2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "ContrastSmoothSkinningWeightsOpBinding.h" - -#include "IECoreScene/ContrastSmoothSkinningWeightsOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindContrastSmoothSkinningWeightsOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.h b/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.h deleted file mode 100644 index 46c429a4b3..0000000000 --- a/src/IECoreScene/bindings/ContrastSmoothSkinningWeightsOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_CONTRASTSMOOTHSKINNINGWEIGHTSOPBINDING_H -#define IECORESCENEMODULE_CONTRASTSMOOTHSKINNINGWEIGHTSOPBINDING_H - -namespace IECoreSceneModule -{ -void bindContrastSmoothSkinningWeightsOp(); -} - -#endif // IECORESCENEMODULE_CONTRASTSMOOTHSKINNINGWEIGHTSOPBINDING_H diff --git a/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.cpp b/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.cpp deleted file mode 100644 index 4bd2d5a2ef..0000000000 --- a/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "DecompressSmoothSkinningDataOpBinding.h" - -#include "IECoreScene/DecompressSmoothSkinningDataOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindDecompressSmoothSkinningDataOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.h b/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.h deleted file mode 100644 index 6620867ed9..0000000000 --- a/src/IECoreScene/bindings/DecompressSmoothSkinningDataOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_DECOMPRESSSMOOTHSKINNINGDATAOPBINDING_H -#define IECORESCENEMODULE_DECOMPRESSSMOOTHSKINNINGDATAOPBINDING_H - -namespace IECoreSceneModule -{ -void bindDecompressSmoothSkinningDataOp(); -} - -#endif // IECORESCENEMODULE_DECOMPRESSSMOOTHSKINNINGDATAOPBINDING_H diff --git a/src/IECoreScene/bindings/IECoreScene.cpp b/src/IECoreScene/bindings/IECoreScene.cpp index b85d5318c9..47d1a87626 100644 --- a/src/IECoreScene/bindings/IECoreScene.cpp +++ b/src/IECoreScene/bindings/IECoreScene.cpp @@ -34,11 +34,8 @@ #include "boost/python.hpp" -#include "AddSmoothSkinningInfluencesOpBinding.h" #include "CameraBinding.h" #include "ClippingPlaneBinding.h" -#include "CompressSmoothSkinningDataOpBinding.h" -#include "ContrastSmoothSkinningWeightsOpBinding.h" #include "CoordinateSystemBinding.h" #include "CurveLineariserBinding.h" #include "CurveTangentsOpBinding.h" @@ -46,12 +43,10 @@ #include "CurvesMergeOpBinding.h" #include "CurvesPrimitiveBinding.h" #include "CurvesPrimitiveEvaluatorBinding.h" -#include "DecompressSmoothSkinningDataOpBinding.h" #include "DiskPrimitiveBinding.h" #include "ExternalProceduralBinding.h" #include "FaceVaryingPromotionOpBinding.h" #include "FontBinding.h" -#include "LimitSmoothSkinningInfluencesOpBinding.h" #include "LinkedSceneBinding.h" #include "MeshAlgoBinding.h" #include "MeshMergeOpBinding.h" @@ -61,10 +56,8 @@ #include "MeshPrimitiveEvaluatorBinding.h" #include "MeshPrimitiveShrinkWrapOpBinding.h" #include "MeshVertexReorderOpBinding.h" -#include "MixSmoothSkinningWeightsOpBinding.h" #include "NParticleReaderBinding.h" #include "NURBSPrimitiveBinding.h" -#include "NormalizeSmoothSkinningWeightsOpBinding.h" #include "OBJReaderBinding.h" #include "OutputBinding.h" #include "PDCParticleReaderBinding.h" @@ -72,7 +65,6 @@ #include "ParticleReaderBinding.h" #include "ParticleWriterBinding.h" #include "PatchMeshPrimitiveBinding.h" -#include "PointSmoothSkinningOpBinding.h" #include "PointsAlgoBinding.h" #include "PointsPrimitiveBinding.h" #include "PointsPrimitiveEvaluatorBinding.h" @@ -80,9 +72,7 @@ #include "PrimitiveEvaluatorBinding.h" #include "PrimitiveOpBinding.h" #include "PrimitiveVariableBinding.h" -#include "RemoveSmoothSkinningInfluencesOpBinding.h" #include "RenderableBinding.h" -#include "ReorderSmoothSkinningInfluencesOpBinding.h" #include "SampledSceneInterfaceBinding.h" #include "SceneCacheBinding.h" #include "SceneInterfaceBinding.h" @@ -90,11 +80,8 @@ #include "ShaderNetworkBinding.h" #include "ShaderNetworkAlgoBinding.h" #include "SharedSceneInterfacesBinding.h" -#include "SmoothSkinningDataBinding.h" -#include "SmoothSmoothSkinningWeightsOpBinding.h" #include "SpherePrimitiveBinding.h" #include "SpherePrimitiveEvaluatorBinding.h" -#include "TransferSmoothSkinningWeightsOpBinding.h" #include "TransformOpBinding.h" #include "TriangulateOpBinding.h" #include "TriangulatorBinding.h" @@ -157,21 +144,8 @@ BOOST_PYTHON_MODULE(_IECoreScene) bindCurvesPrimitiveEvaluator(); bindCurveLineariser(); bindCurveTangentsOp(); - bindSmoothSkinningData(); bindFaceVaryingPromotionOp(); - bindCompressSmoothSkinningDataOp(); - bindDecompressSmoothSkinningDataOp(); - bindReorderSmoothSkinningInfluencesOp(); - bindNormalizeSmoothSkinningWeightsOp(); - bindLimitSmoothSkinningInfluencesOp(); - bindMixSmoothSkinningWeightsOp(); - bindSmoothSmoothSkinningWeightsOp(); - bindPointSmoothSkinningOp(); - bindAddSmoothSkinningInfluencesOp(); - bindRemoveSmoothSkinningInfluencesOp(); - bindTransferSmoothSkinningWeightsOp(); bindPointsPrimitiveEvaluator(); - bindContrastSmoothSkinningWeightsOp(); bindDiskPrimitive(); bindSceneInterface(); bindSharedSceneInterfaces(); diff --git a/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.cpp b/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.cpp deleted file mode 100644 index 7da0a76d8c..0000000000 --- a/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.cpp +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "LimitSmoothSkinningInfluencesOpBinding.h" - -#include "IECoreScene/LimitSmoothSkinningInfluencesOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindLimitSmoothSkinningInfluencesOp() -{ - object o = RunTimeTypedClass() - .def( init<>() ) - ; - - scope s( o ); - - enum_< LimitSmoothSkinningInfluencesOp::Mode >( "Mode" ) - .value( "WeightLimit", LimitSmoothSkinningInfluencesOp::WeightLimit ) - .value( "MaxInfluences", LimitSmoothSkinningInfluencesOp::MaxInfluences ) - .value( "Indexed", LimitSmoothSkinningInfluencesOp::Indexed ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.h b/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.h deleted file mode 100644 index 807e761da0..0000000000 --- a/src/IECoreScene/bindings/LimitSmoothSkinningInfluencesOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_LIMITSMOOTHSKINNINGINFLUENCESOPBINDING_H -#define IECORESCENEMODULE_LIMITSMOOTHSKINNINGINFLUENCESOPBINDING_H - -namespace IECoreSceneModule -{ -void bindLimitSmoothSkinningInfluencesOp(); -} - -#endif // IECORESCENEMODULE_LIMITSMOOTHSKINNINGINFLUENCESOPBINDING_H diff --git a/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.cpp b/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.cpp deleted file mode 100644 index 36c5287a65..0000000000 --- a/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "MixSmoothSkinningWeightsOpBinding.h" - -#include "IECoreScene/MixSmoothSkinningWeightsOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindMixSmoothSkinningWeightsOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.h b/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.h deleted file mode 100644 index 0d0230a780..0000000000 --- a/src/IECoreScene/bindings/MixSmoothSkinningWeightsOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_MIXSMOOTHSKINNINGWEIGHTSOPBINDING_H -#define IECORESCENEMODULE_MIXSMOOTHSKINNINGWEIGHTSOPBINDING_H - -namespace IECoreSceneModule -{ -void bindMixSmoothSkinningWeightsOp(); -} - -#endif // IECORESCENEMODULE_MIXSMOOTHSKINNINGWEIGHTSOPBINDING_H diff --git a/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.cpp b/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.cpp deleted file mode 100644 index 3481326fe0..0000000000 --- a/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "NormalizeSmoothSkinningWeightsOpBinding.h" - -#include "IECoreScene/NormalizeSmoothSkinningWeightsOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindNormalizeSmoothSkinningWeightsOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.h b/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.h deleted file mode 100644 index b8cd909907..0000000000 --- a/src/IECoreScene/bindings/NormalizeSmoothSkinningWeightsOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_NORMALIZESMOOTHSKINNINGWEIGHTSOPBINDING_H -#define IECORESCENEMODULE_NORMALIZESMOOTHSKINNINGWEIGHTSOPBINDING_H - -namespace IECoreSceneModule -{ -void bindNormalizeSmoothSkinningWeightsOp(); -} - -#endif // IECORESCENEMODULE_NORMALIZESMOOTHSKINNINGWEIGHTSOPBINDING_H diff --git a/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.cpp b/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.cpp deleted file mode 100644 index aed17961e2..0000000000 --- a/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.cpp +++ /dev/null @@ -1,71 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2009, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "PointSmoothSkinningOpBinding.h" - -#include "IECoreScene/PointSmoothSkinningOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -#include "IECore/CompoundObject.h" -#include "IECore/Object.h" -#include "IECore/Parameter.h" - -using namespace boost; -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindPointSmoothSkinningOp() -{ - scope opScope = RunTimeTypedClass() - .def( init<>() ) - ; - - enum_< PointSmoothSkinningOp::Blend >( "Blend" ) - .value( "Linear", PointSmoothSkinningOp::Linear ) - ; - - -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.h b/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.h deleted file mode 100644 index 142c050535..0000000000 --- a/src/IECoreScene/bindings/PointSmoothSkinningOpBinding.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREPYTHON_POINTSMOOTHSKINNINGOPBINDING_H -#define IE_COREPYTHON_POINTSMOOTHSKINNINGOPBINDING_H - -namespace IECoreSceneModule -{ -void bindPointSmoothSkinningOp(); -} - -#endif //IE_COREPYTHON_POINTSMOOTHSKINNINGOPBINDING_H diff --git a/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.cpp b/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.cpp deleted file mode 100644 index 0d2ce34c71..0000000000 --- a/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.cpp +++ /dev/null @@ -1,65 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "RemoveSmoothSkinningInfluencesOpBinding.h" - -#include "IECoreScene/RemoveSmoothSkinningInfluencesOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindRemoveSmoothSkinningInfluencesOp() -{ - object o = RunTimeTypedClass() - .def( init<>() ) - ; - - scope s( o ); - - enum_< RemoveSmoothSkinningInfluencesOp::Mode >( "Mode" ) - .value( "Named", RemoveSmoothSkinningInfluencesOp::Named ) - .value( "Indexed", RemoveSmoothSkinningInfluencesOp::Indexed ) - .value( "Weightless", RemoveSmoothSkinningInfluencesOp::Weightless ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.h b/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.h deleted file mode 100644 index 6687fd7cd3..0000000000 --- a/src/IECoreScene/bindings/RemoveSmoothSkinningInfluencesOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_REMOVESMOOTHSKINNINGINFLUENCESOPBINDING_H -#define IECORESCENEMODULE_REMOVESMOOTHSKINNINGINFLUENCESOPBINDING_H - -namespace IECoreSceneModule -{ -void bindRemoveSmoothSkinningInfluencesOp(); -} - -#endif // IECORESCENEMODULE_REMOVESMOOTHSKINNINGINFLUENCESOPBINDING_H diff --git a/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.cpp b/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.cpp deleted file mode 100644 index 90133bed14..0000000000 --- a/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "ReorderSmoothSkinningInfluencesOpBinding.h" - -#include "IECoreScene/ReorderSmoothSkinningInfluencesOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindReorderSmoothSkinningInfluencesOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.h b/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.h deleted file mode 100644 index 2074ce8c99..0000000000 --- a/src/IECoreScene/bindings/ReorderSmoothSkinningInfluencesOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_REORDERSMOOTHSKINNINGINFLUENCESOPBINDING_H -#define IECORESCENEMODULE_REORDERSMOOTHSKINNINGINFLUENCESOPBINDING_H - -namespace IECoreSceneModule -{ -void bindReorderSmoothSkinningInfluencesOp(); -} - -#endif // IECORESCENEMODULE_REORDERSMOOTHSKINNINGINFLUENCESOPBINDING_H diff --git a/src/IECoreScene/bindings/SmoothSkinningDataBinding.cpp b/src/IECoreScene/bindings/SmoothSkinningDataBinding.cpp deleted file mode 100644 index 7356d7d7b0..0000000000 --- a/src/IECoreScene/bindings/SmoothSkinningDataBinding.cpp +++ /dev/null @@ -1,101 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "SmoothSkinningDataBinding.h" - -#include "IECoreScene/SmoothSkinningData.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECore; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - - static StringVectorDataPtr influenceNames( SmoothSkinningData &p ) - { - return p.influenceNames(); - } - - static M44fVectorDataPtr influencePose( SmoothSkinningData &p ) - { - return p.influencePose(); - } - - static IntVectorDataPtr pointIndexOffsets( SmoothSkinningData &p ) - { - return p.pointIndexOffsets(); - } - - static IntVectorDataPtr pointInfluenceCounts( SmoothSkinningData &p ) - { - return p.pointInfluenceCounts(); - } - - static IntVectorDataPtr pointInfluenceIndices( SmoothSkinningData &p ) - { - return p.pointInfluenceIndices(); - } - - static FloatVectorDataPtr pointInfluenceWeights( SmoothSkinningData &p ) - { - return p.pointInfluenceWeights(); - } - - - void bindSmoothSkinningData() - { - RunTimeTypedClass() - .def( init<>() ) - .def( init() ) - .def( "influenceNames", &influenceNames, "A copy of the list of influence object names" ) - .def( "influencePose", &influencePose , "A copy of the list of influence pose matrices (bindPose)" ) - .def( "pointIndexOffsets", &pointIndexOffsets , "A copy of the list of per point offsets into the influence index and weight data") - .def( "pointInfluenceCounts", &pointInfluenceCounts, "A copy of the list of per point number of influence objects" ) - .def( "pointInfluenceIndices", &pointInfluenceIndices, "A copy of the list of per point per influence indices" ) - .def( "pointInfluenceWeights", &pointInfluenceWeights, "A copy of the list of per point per influence weights" ) - .def( "validate", &SmoothSkinningData::validate, "Validate the smooth skinning data in the object" ) - ; - - } - -} diff --git a/src/IECoreScene/bindings/SmoothSkinningDataBinding.h b/src/IECoreScene/bindings/SmoothSkinningDataBinding.h deleted file mode 100644 index 8e405efd6b..0000000000 --- a/src/IECoreScene/bindings/SmoothSkinningDataBinding.h +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008, Image Engine Design Inc. All rights reserved. -// -// Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -// its affiliates and/or its licensors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_COREPYTHON_SMOOTHSKINNINGDATABINDING_H -#define IE_COREPYTHON_SMOOTHSKINNINGDATABINDING_H - -namespace IECoreSceneModule -{ - -void bindSmoothSkinningData(); - -} - -#endif // IE_COREPYTHON_SMOOTHSKINNINGDATABINDING_H diff --git a/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.cpp b/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.cpp deleted file mode 100644 index 71090ceaf6..0000000000 --- a/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "SmoothSmoothSkinningWeightsOpBinding.h" - -#include "IECoreScene/SmoothSmoothSkinningWeightsOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindSmoothSmoothSkinningWeightsOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.h b/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.h deleted file mode 100644 index 965d3a00a0..0000000000 --- a/src/IECoreScene/bindings/SmoothSmoothSkinningWeightsOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_SMOOTHSMOOTHSKINNINGWEIGHTSOPBINDING_H -#define IECORESCENEMODULE_SMOOTHSMOOTHSKINNINGWEIGHTSOPBINDING_H - -namespace IECoreSceneModule -{ -void bindSmoothSmoothSkinningWeightsOp(); -} - -#endif // IECORESCENEMODULE_SMOOTHSMOOTHSKINNINGWEIGHTSOPBINDING_H diff --git a/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.cpp b/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.cpp deleted file mode 100644 index 4f814f1d00..0000000000 --- a/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.cpp +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "TransferSmoothSkinningWeightsOpBinding.h" - -#include "IECoreScene/TransferSmoothSkinningWeightsOp.h" - -#include "IECorePython/RunTimeTypedBinding.h" - -using namespace boost::python; -using namespace IECorePython; -using namespace IECoreScene; - -namespace IECoreSceneModule -{ - -void bindTransferSmoothSkinningWeightsOp() -{ - RunTimeTypedClass() - .def( init<>() ) - ; -} - -} // namespace IECoreSceneModule diff --git a/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.h b/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.h deleted file mode 100644 index 3be4114204..0000000000 --- a/src/IECoreScene/bindings/TransferSmoothSkinningWeightsOpBinding.h +++ /dev/null @@ -1,43 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORESCENEMODULE_TRANSFERSMOOTHSKINNINGWEIGHTSOPBINDING_H -#define IECORESCENEMODULE_TRANSFERSMOOTHSKINNINGWEIGHTSOPBINDING_H - -namespace IECoreSceneModule -{ -void bindTransferSmoothSkinningWeightsOp(); -} - -#endif // IECORESCENEMODULE_TRANSFERSMOOTHSKINNINGWEIGHTSOPBINDING_H diff --git a/src/IECoreScene/bindings/TypedObjectParameterBinding.cpp b/src/IECoreScene/bindings/TypedObjectParameterBinding.cpp index 8cb42b2d01..30f45ad899 100644 --- a/src/IECoreScene/bindings/TypedObjectParameterBinding.cpp +++ b/src/IECoreScene/bindings/TypedObjectParameterBinding.cpp @@ -41,7 +41,6 @@ #include "IECoreScene/Renderable.h" #include "IECoreScene/Shader.h" #include "IECoreScene/VisibleRenderable.h" -#include "IECoreScene/SmoothSkinningData.h" #include "IECoreScene/Primitive.h" #include "IECoreScene/MeshPrimitive.h" #include "IECoreScene/CurvesPrimitive.h" @@ -90,7 +89,6 @@ void IECoreSceneModule::bindTypedObjectParameter() ::bindTypedObjectParameter(); ::bindTypedObjectParameter(); ::bindTypedObjectParameter(); - ::bindTypedObjectParameter(); ::bindTypedObjectParameter(); ::bindTypedObjectParameter(); diff --git a/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py deleted file mode 100644 index b44e747795..0000000000 --- a/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py +++ /dev/null @@ -1,294 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class AddAndRemoveSmoothSkinningInfluencesOpTest( unittest.TestCase ) : - - def createSSD( self, names, poses, indices ) : - - offsets = IECore.IntVectorData( [0, 2, 5, 6, 8] ) - counts = IECore.IntVectorData( [2, 3, 1, 2, 3] ) - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.0, 0.1, 1.2, 0.8, 0.4, 0.6, 0.4] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2, 0, 1, 2] ) - - return self.createSSD( names, poses, indices ) - - def added( self ) : - - names = IECore.StringVectorData( [ 'newA', 'jointA', 'newC', 'newB', 'jointB', 'jointC', 'newD' ] ) - poses = IECore.M44fVectorData( [ imath.M44f(4), imath.M44f(1), imath.M44f(6), imath.M44f(5), imath.M44f(2), imath.M44f(3), imath.M44f(7) ] ) - indices = IECore.IntVectorData( [1, 4, 1, 4, 5, 4, 4, 5, 1, 4, 5] ) - - return self.createSSD( names, poses, indices ) - - def removed( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'newC', 'newB', 'jointC' ] ) - poses = IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(6), imath.M44f(5), imath.M44f(3) ] ) - offsets = IECore.IntVectorData( [0, 1, 3, 3, 4] ) - counts = IECore.IntVectorData( [1, 2, 0, 1, 2] ) - indices = IECore.IntVectorData( [0, 0, 3, 3, 0, 3] ) - weights = IECore.FloatVectorData( [0.7, 0.2, 0.0, 0.8, 0.4, 0.4] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def testTypes( self ) : - """ Test AddSmoothSkinningInfluencesOp and RemoveSmoothSkinningInfluencesOp types""" - - ssd = self.original() - - op = IECoreScene.AddSmoothSkinningInfluencesOp() - self.assertEqual( type(op), IECoreScene.AddSmoothSkinningInfluencesOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.AddSmoothSkinningInfluencesOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - self.assertEqual( type(op), IECoreScene.RemoveSmoothSkinningInfluencesOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.RemoveSmoothSkinningInfluencesOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testAddingNothing( self ) : - """ Test AddSmoothSkinningInfluencesOp with no new influences""" - - ssd = self.original() - - op = IECoreScene.AddSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testAdding( self ) : - """ Test AddSmoothSkinningInfluencesOp""" - - ssd = self.original() - - op = IECoreScene.AddSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "newB", "newC", "newD" ] ) ) - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(4), imath.M44f(5), imath.M44f(6), imath.M44f(7) ] ) ) - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 0, 2, 2, 6 ] ) ) - result = op.operate() - - self.assertNotEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertNotEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - added = self.added() - self.assertEqual( result.influenceNames(), added.influenceNames() ) - self.assertEqual( result.influencePose(), added.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), added.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), added.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), added.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), added.pointInfluenceWeights() ) - self.assertEqual( result, added ) - - def testRemovingNothing( self ) : - """ Test RemoveSmoothSkinningInfluencesOp with no new influences""" - - ssd = self.original() - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testRemovingNamedMode( self ) : - """ Test RemoveSmoothSkinningInfluencesOp in named mode""" - - ssd = self.added() - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.RemoveSmoothSkinningInfluencesOp.Mode.Named ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "jointB", "newD" ] ) ) - result = op.operate() - - self.assertNotEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertNotEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - removed = self.removed() - self.assertEqual( result.influenceNames(), removed.influenceNames() ) - self.assertEqual( result.influencePose(), removed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), removed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), removed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), removed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), removed.pointInfluenceWeights() ) - self.assertEqual( result, removed ) - - def testRemovingIndexedMode( self ) : - """ Test RemoveSmoothSkinningInfluencesOp in index mode""" - - ssd = self.added() - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.RemoveSmoothSkinningInfluencesOp.Mode.Indexed ) - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 0, 4, 6 ] ) ) - result = op.operate() - - self.assertNotEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertNotEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - removed = self.removed() - self.assertEqual( result.influenceNames(), removed.influenceNames() ) - self.assertEqual( result.influencePose(), removed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), removed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), removed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), removed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), removed.pointInfluenceWeights() ) - self.assertEqual( result, removed ) - - def testRemovingWeightlessMode( self ) : - """ Test RemoveSmoothSkinningInfluencesOp in weightless mode""" - - ssd = self.added() - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.RemoveSmoothSkinningInfluencesOp.Mode.Weightless ) - result = op.operate() - - self.assertNotEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertNotEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - removed = self.original() - self.assertEqual( result.influenceNames(), removed.influenceNames() ) - self.assertEqual( result.influencePose(), removed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), removed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), removed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), removed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), removed.pointInfluenceWeights() ) - self.assertEqual( result, removed ) - - def testAddOpErrorStates( self ) : - """ Test AddSmoothSkinningInfluencesOp with various error states""" - - ssd = self.original() - - op = IECoreScene.AddSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "newB", "newC" ] ) ) - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(2) ] ) ) - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 1, 3 ] ) ) - - # wrong number of pose matrices - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of indices - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(2), imath.M44f(3) ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # index validity - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 1, 3, 6 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # existing influenceName - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 1, 2, 3 ] ) ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "jointA", "newB", "newC" ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - def testRemoveOpErrorStates( self ) : - """ Test RemoveSmoothSkinningInfluencesOp with various error states""" - - ssd = self.original() - - op = IECoreScene.RemoveSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "newB", "newC" ] ) ) - - # index validity - op.parameters()['mode'].setValue( IECoreScene.RemoveSmoothSkinningInfluencesOp.Mode.Indexed ) - op.parameters()['indices'].setValue( IECore.IntVectorData( [ 1, 3 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # name validity - op.parameters()['mode'].setValue( IECoreScene.RemoveSmoothSkinningInfluencesOp.Mode.Named ) - op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "jointFAKE", "newB", "newC" ] ) ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/All.py b/test/IECoreScene/All.py index 9a34a90410..8b8194178a 100644 --- a/test/IECoreScene/All.py +++ b/test/IECoreScene/All.py @@ -72,19 +72,9 @@ from CurvesPrimitiveEvaluatorTest import CurvesPrimitiveEvaluatorTest from CurveLineariserTest import CurveLineariserTest from CurveTangentsOpTest import CurveTangentsOpTest -from SmoothSkinningDataTest import * from PrimitiveVariableTest import PrimitiveVariableTest from FaceVaryingPromotionOpTest import FaceVaryingPromotionOpTest -from CompressAndDecompressSmoothSkinningDataOpsTest import CompressAndDecompressSmoothSkinningDataOpsTest -from ReorderSmoothSkinningInfluencesOpTest import ReorderSmoothSkinningInfluencesOpTest -from NormalizeSmoothSkinningWeightsOpTest import NormalizeSmoothSkinningWeightsOpTest -from LimitSmoothSkinningInfluencesOpTest import LimitSmoothSkinningInfluencesOpTest -from MixSmoothSkinningWeightsOpTest import MixSmoothSkinningWeightsOpTest -from SmoothSmoothSkinningWeightsOpTest import SmoothSmoothSkinningWeightsOpTest -from PointSmoothSkinningOpTest import PointSmoothSkinningOpTest -from AddAndRemoveSmoothSkinningInfluencesOpTest import AddAndRemoveSmoothSkinningInfluencesOpTest from PointsPrimitiveEvaluatorTest import PointsPrimitiveEvaluatorTest -from ContrastSmoothSkinningWeightsOpTest import ContrastSmoothSkinningWeightsOpTest from DiskPrimitiveTest import DiskPrimitiveTest from SWAReaderTest import SWAReaderTest from SceneCacheTest import SceneCacheTest @@ -100,7 +90,6 @@ from ShaderNetworkAlgoTest import ShaderNetworkAlgoTest from SharedSceneInterfacesTest import SharedSceneInterfacesTest from SceneInterfaceTest import SceneInterfaceTest -from TransferSmoothSkinningWeightsOpTest import TransferSmoothSkinningWeightsOpTest from TypedPrimitiveOp import TestTypedPrimitiveOp if IECore.withFreeType() : diff --git a/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py b/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py deleted file mode 100644 index 883b33785b..0000000000 --- a/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py +++ /dev/null @@ -1,228 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class CompressAndDecompressSmoothSkinningDataOpsTest( unittest.TestCase ) : - - def compressed( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) - offsets = IECore.IntVectorData( [0, 2, 4] ) - counts = IECore.IntVectorData( [2, 2, 1] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 1] ) - weights = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 1.0] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def noncompressed( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) - offsets = IECore.IntVectorData( [0, 2, 5] ) - counts = IECore.IntVectorData( [2, 3, 1] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1] ) - weights = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 0.0, 1.0] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def decompressed( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) - offsets = IECore.IntVectorData( [0, 3, 6] ) - counts = IECore.IntVectorData( [3, 3, 3] ) - indices = IECore.IntVectorData( [0, 1, 2, 0, 1, 2, 0, 1, 2] ) - weights = IECore.FloatVectorData( [0.5, 0.5, 0.0, 0.2, 0.8, 0.0, 0.0, 1.0, 0.0] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def testTypes( self ) : - """ Test CompressSmoothSkinningDataOp and DecompressSmoothSkinningDataOp types""" - - ssd = self.compressed() - - op = IECoreScene.CompressSmoothSkinningDataOp() - self.assertEqual( type(op), IECoreScene.CompressSmoothSkinningDataOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.CompressSmoothSkinningDataOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - op = IECoreScene.DecompressSmoothSkinningDataOp() - self.assertEqual( type(op), IECoreScene.DecompressSmoothSkinningDataOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.DecompressSmoothSkinningDataOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testCompressingCompressed( self ) : - """ Test CompressSmoothSkinningDataOp with compressed SmoothSkinningData""" - - ssd = self.compressed() - - op = IECoreScene.CompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testCompressingNoncompressed( self ) : - """ Test CompressSmoothSkinningDataOp with non-compressed SmoothSkinningData""" - - ssd = self.noncompressed() - - op = IECoreScene.CompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - self.assertNotEqual( result, ssd ) - - compressed = self.compressed() - self.assertEqual( result.pointIndexOffsets(), compressed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), compressed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), compressed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), compressed.pointInfluenceWeights() ) - self.assertEqual( result, compressed ) - - - def testCompressingDecompressed( self ) : - """ Test CompressSmoothSkinningDataOp with decompressed SmoothSkinningData""" - - ssd = self.decompressed() - - op = IECoreScene.CompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - self.assertNotEqual( result, ssd ) - - compressed = self.compressed() - self.assertEqual( result.pointIndexOffsets(), compressed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), compressed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), compressed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), compressed.pointInfluenceWeights() ) - self.assertEqual( result, compressed ) - - def testCompressingWithThreshold( self ) : - """ Test CompressSmoothSkinningDataOp threshold parameter""" - - ssd = self.noncompressed() - - op = IECoreScene.CompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['threshold'].setNumericValue( 0.5 ) - result = op.operate() - self.assertNotEqual( result, ssd ) - - self.assertNotEqual( result, self.compressed() ) - - for val in result.pointInfluenceWeights() : - self.assertTrue( val > 0.5 ) - - self.assertEqual( result.pointIndexOffsets(), IECore.IntVectorData( [0, 0, 1] ) ) - self.assertEqual( result.pointInfluenceCounts(), IECore.IntVectorData( [0, 1, 1] ) ) - self.assertEqual( result.pointInfluenceIndices(), IECore.IntVectorData( [1, 1] ) ) - self.assertEqual( result.pointInfluenceWeights(), IECore.FloatVectorData( [0.8, 1.0] ) ) - - decompressed = self.decompressed() - op.parameters()['input'].setValue( decompressed ) - result2 = op.operate() - self.assertNotEqual( result2, decompressed ) - self.assertEqual( result2, result ) - - def testDecompressingCompressed( self ) : - """ Test DeompressSmoothSkinningDataOp with compressed SmoothSkinningData""" - - ssd = self.compressed() - - op = IECoreScene.DecompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - self.assertNotEqual( result, ssd ) - - decompressed = self.decompressed() - self.assertEqual( result.pointIndexOffsets(), decompressed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), decompressed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), decompressed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), decompressed.pointInfluenceWeights() ) - self.assertEqual( result, decompressed ) - - def testDecompressingNoncompressed( self ) : - """ Test DeompressSmoothSkinningDataOp with compressed SmoothSkinningData""" - - ssd = self.noncompressed() - - op = IECoreScene.DecompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - self.assertNotEqual( result, ssd ) - - decompressed = self.decompressed() - self.assertEqual( result.pointIndexOffsets(), decompressed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), decompressed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), decompressed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), decompressed.pointInfluenceWeights() ) - self.assertEqual( result, decompressed ) - - def testDecompressingDecompressed( self ) : - """ Test DeompressSmoothSkinningDataOp """ - - ssd = self.decompressed() - - op = IECoreScene.DecompressSmoothSkinningDataOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py b/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py deleted file mode 100644 index 35aac18bbd..0000000000 --- a/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py +++ /dev/null @@ -1,304 +0,0 @@ -########################################################################## -# -# Copyright (c) 2011, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class ContrastSmoothSkinningWeightsOpTest( unittest.TestCase ) : - - def mesh( self ) : - - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ - 0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, - 8, 9, 11, 10, 10, 11, 13, 12, 12, 13, 15, 14, 14, 15, 1, 0, - 1, 15, 13, 3, 3, 13, 11, 5, 5, 11, 9, 7, 14, 0, 2, 12, - 12, 2, 4, 10, 10, 4, 6, 8 - ] ) - - return IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) - - def createSSD( self, offsets, counts, indices, weights ) : - - names = IECore.StringVectorData( [ "|joint1", "|joint1|joint2", "|joint1|joint2|joint3" ] ) - poses = IECore.M44fVectorData( [ - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) - ] ) - - return IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - def original( self ) : - - offsets = IECore.IntVectorData( [ 0, 1, 2, 4, 6, 7, 8, 10, 12, 14, 16, 17, 18, 20, 22, 23 ] ) - counts = IECore.IntVectorData( [ 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1 ] ) - indices = IECore.IntVectorData( [ 0, 0, 0, 1, 0, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 0 ] ) - - weights = IECore.FloatVectorData( [ - 1, 1, 0.8, 0.2, 0.8, 0.2, 1, 1, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 1, 1, 0.8, 0.2, 0.8, 0.2, 1, 1 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def __testContrast( self, center ) : - - ssd = self.original() - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - origWeights = decompressedOrig.pointInfluenceWeights() - - # ratio 0.2 iterations 1 - op = IECoreScene.ContrastSmoothSkinningWeightsOp() - op.parameters()['copyInput'].setValue( True ) - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['contrastCenter'].setValue( center ) - op.parameters()['contrastRatio'].setValue( 0.2 ) - op.parameters()['iterations'].setValue( 1 ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio02iteration1 = dop.operate() - ratio02iteration1Weights = ratio02iteration1.pointInfluenceWeights() - - # ratio 0.5 iterations 1 - op.parameters()['contrastRatio'].setValue( 0.5 ) - op.parameters()['iterations'].setValue( 1 ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio05iteration1 = dop.operate() - ratio05iteration1Weights = ratio05iteration1.pointInfluenceWeights() - - # ratio 0.8 iterations 1 - op.parameters()['contrastRatio'].setValue( 0.8 ) - op.parameters()['iterations'].setValue( 1 ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio08iteration1 = dop.operate() - ratio08iteration1Weights = ratio08iteration1.pointInfluenceWeights() - - # ratio 0.2 iterations 2 - op.parameters()['contrastRatio'].setValue( 0.2 ) - op.parameters()['iterations'].setValue( 2 ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio02iteration2 = dop.operate() - ratio02iteration2Weights = ratio02iteration2.pointInfluenceWeights() - - # ratio 0.5 iterations 2 - op.parameters()['contrastRatio'].setValue( 0.5 ) - op.parameters()['iterations'].setValue( 2 ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio05iteration2 = dop.operate() - ratio05iteration2Weights = ratio05iteration2.pointInfluenceWeights() - - # ratio 0.8 iterations 2 - op.parameters()['contrastRatio'].setValue( 0.8 ) - op.parameters()['iterations'].setValue( 2 ) - result = op.operate() - dop.parameters()['input'].setValue( result ) - ratio08iteration2 = dop.operate() - ratio08iteration2Weights = ratio08iteration2.pointInfluenceWeights() - - for i in range( 0, origWeights.size() ) : - if origWeights[i] > center : - - if origWeights[i] < 1 : - self.assertTrue( ratio02iteration1Weights[i] > origWeights[i] ) - self.assertTrue( ratio05iteration1Weights[i] > ratio02iteration1Weights[i] ) - self.assertTrue( ratio08iteration1Weights[i] > ratio05iteration1Weights[i] ) - - self.assertTrue( ratio02iteration2Weights[i] > origWeights[i] ) - self.assertTrue( ratio05iteration2Weights[i] > ratio02iteration2Weights[i] ) - self.assertTrue( ratio08iteration2Weights[i] > ratio05iteration2Weights[i] ) - - self.assertTrue( ratio02iteration2Weights[i] > ratio02iteration1Weights[i] ) - self.assertTrue( ratio05iteration2Weights[i] > ratio05iteration1Weights[i] ) - self.assertTrue( ratio08iteration2Weights[i] > ratio08iteration1Weights[i] ) - - elif origWeights[i] < center : - - if origWeights[i] > 0 : - self.assertTrue( ratio02iteration1Weights[i] < origWeights[i] ) - self.assertTrue( ratio05iteration1Weights[i] < ratio02iteration1Weights[i] ) - self.assertTrue( ratio08iteration1Weights[i] < ratio05iteration1Weights[i] ) - - self.assertTrue( ratio02iteration2Weights[i] < origWeights[i] ) - self.assertTrue( ratio05iteration2Weights[i] < ratio02iteration2Weights[i] ) - self.assertTrue( ratio08iteration2Weights[i] < ratio05iteration2Weights[i] ) - - self.assertTrue( ratio02iteration2Weights[i] < ratio02iteration1Weights[i] ) - self.assertTrue( ratio05iteration2Weights[i] < ratio05iteration1Weights[i] ) - self.assertTrue( ratio08iteration2Weights[i] < ratio08iteration1Weights[i] ) - - else : - - self.assertEqual( ratio02iteration1Weights[i], origWeights[i] ) - self.assertEqual( ratio05iteration1Weights[i], ratio02iteration1Weights[i] ) - self.assertEqual( ratio08iteration1Weights[i], ratio05iteration1Weights[i] ) - - self.assertEqual( ratio02iteration2Weights[i], origWeights[i] ) - self.assertEqual( ratio05iteration2Weights[i], ratio02iteration2Weights[i] ) - self.assertEqual( ratio08iteration2Weights[i], ratio05iteration2Weights[i] ) - - self.assertEqual( ratio02iteration2Weights[i], ratio02iteration1Weights[i] ) - self.assertEqual( ratio05iteration2Weights[i], ratio05iteration1Weights[i] ) - self.assertEqual( ratio08iteration2Weights[i], ratio08iteration1Weights[i] ) - - def testContrast( self ): - """ Test ContrastSmoothSkinningWeightsOp changing ratio and iterations""" - self.__testContrast( center = 0.4 ) - self.__testContrast( center = 0.5 ) - self.__testContrast( center = 0.6 ) - - def testLocks( self ) : - """ Test ContrastSmoothSkinningWeightsOp locking mechanism""" - - ssd = self.original() - op = IECoreScene.ContrastSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['contrastRatio'].setValue( 1.0 ) - op.parameters()['iterations'].setValue( 3 ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, False ] ) ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - # make sure locked weights did not change and the rest has changed. - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - if resultIndices[i] == 0 : - self.assertEqual( resultWeights[i], origWeights[i] ) - elif not origWeights[i] in [ 0, 0.5, 1 ]: - self.assertNotEqual( resultWeights[i], origWeights[i] ) - - def testVertexSelection( self ) : - """ Test ContrastSmoothSkinningWeightsOp using selected vertices""" - - ssd = self.original() - op = IECoreScene.ContrastSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['contrastRatio'].setValue( 0.5 ) - op.parameters()['iterations'].setValue( 2 ) - op.parameters()['applyLocks'].setValue( False ) - op.parameters()['vertexIndices'].setFrameListValue( IECore.FrameList.parse( "2-4,10-12" ) ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - # make sure only selected vertices changed and the rest is unchanged. - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultOffsets = decompressedResult.pointIndexOffsets() - resultCounts = decompressedResult.pointInfluenceCounts() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - frames = op.parameters()['vertexIndices'].getFrameListValue().asList() - nonSelectedVerts = [ x for x in range( 0, resultOffsets.size() ) if x not in frames ] - for i in range( 0, resultOffsets.size() ) : - - if i in frames : - for j in range( 0, resultCounts[i] ) : - current = resultOffsets[i] + j - if origWeights[current] > 0 and origWeights[current] < 1: - self.assertNotEqual( resultWeights[current], origWeights[current] ) - else : - for j in range( 0, resultCounts[i] ) : - current = resultOffsets[i] + j - self.assertEqual( resultWeights[current], origWeights[current] ) - - def testErrorStates( self ) : - """ Test ContrastSmoothSkinningWeightsOp with various error states""" - - ssd = self.original() - op = IECoreScene.ContrastSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - - # bad mesh - op.parameters()['mesh'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of verts - op.parameters()['mesh'].setValue( op.parameters()['mesh'].defaultValue ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of locks - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, True, False ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # invalid vertex ids - op.parameters()['applyLocks'].setValue( False ) - op.parameters()['vertexIndices'].setFrameListValue( IECore.FrameList.parse( "10-18" ) ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py deleted file mode 100644 index ab295a59e0..0000000000 --- a/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py +++ /dev/null @@ -1,370 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class LimitSmoothSkinningInfluencesOpTest( unittest.TestCase ) : - - def createSSD( self, weights ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - offsets = IECore.IntVectorData( [0, 2, 5, 6, 8] ) - counts = IECore.IntVectorData( [2, 3, 1, 2, 3] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2, 0, 1, 2] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.0, 0.1, 1.2, 0.8, 0.4, 0.6, 0.4] ) - - return self.createSSD( weights ) - - def weightLimited( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.0, 0.6, 0.0, 0.0, 1.2, 0.8, 0.0, 0.6, 0.0] ) - - return self.createSSD( weights ) - - def weightLimitedWithLocks( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.0, 0.0, 1.2, 0.8, 0.4, 0.6, 0.0] ) - - return self.createSSD( weights ) - - def maxInfluenced( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.0, 0.1, 1.2, 0.8, 0.0, 0.6, 0.4] ) - - return self.createSSD( weights ) - - def maxInfluencedWithLocks( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.0, 0.2, 0.0, 0.0, 0.1, 1.2, 0.0, 0.4, 0.0, 0.0] ) - - return self.createSSD( weights ) - - def indexed( self ) : - - weights = IECore.FloatVectorData( [0.0, 0.7, 0.0, 0.6, 0.0, 0.1, 1.2, 0.0, 0.0, 0.6, 0.0] ) - - return self.createSSD( weights ) - - def compressedAfterIndexed( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - offsets = IECore.IntVectorData( [0, 1, 2, 2, 3] ) - counts = IECore.IntVectorData( [1, 1, 0, 1, 2] ) - indices = IECore.IntVectorData( [0, 0, 2, 0, 2] ) - weights = IECore.FloatVectorData( [0.7, 0.2, 0.8, 0.4, 0.4] ) - - return IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - def testTypes( self ) : - """ Test LimitSmoothSkinningInfluencesOp types""" - - ssd = self.original() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - self.assertEqual( type(op), IECoreScene.LimitSmoothSkinningInfluencesOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.LimitSmoothSkinningInfluencesOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testWeightLimitMode( self ) : - """ Test LimitSmoothSkinningInfluencesOp in weight limit mode""" - - ssd = self.original() - weightLimited = self.weightLimited() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.WeightLimit ) - op.parameters()['minWeight'].setValue( 0.401 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), weightLimited.influenceNames() ) - self.assertEqual( result.influencePose(), weightLimited.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), weightLimited.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), weightLimited.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), weightLimited.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), weightLimited.pointInfluenceWeights() ) - self.assertEqual( result, weightLimited ) - - def testWeightLimitModeWithLocks( self ) : - """ Test LimitSmoothSkinningInfluencesOp locking mechanism in weight limit mode""" - - ssd = self.original() - weightLimited = self.weightLimitedWithLocks() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.WeightLimit ) - op.parameters()['minWeight'].setValue( 0.401 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, False ] ) ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), weightLimited.influenceNames() ) - self.assertEqual( result.influencePose(), weightLimited.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), weightLimited.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), weightLimited.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), weightLimited.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), weightLimited.pointInfluenceWeights() ) - self.assertEqual( result, weightLimited ) - - # make sure locked weights did not change - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - if resultIndices[i] == 0 : - self.assertAlmostEqual( resultWeights[i], origWeights[i], 6 ) - - def testMaxInfluencesModeAllLocked( self ) : - """ Test LimitSmoothSkinningInfluencesOp locking mechanism in weight limit mode with all influences locked""" - - ssd = self.original() - maxInfluenced = self.maxInfluencedWithLocks() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.WeightLimit ) - op.parameters()['minWeight'].setValue( 0.401 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, True, True ] ) ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testMaxInfluencesMode( self ) : - """ Test LimitSmoothSkinningInfluencesOp in max influences mode""" - - ssd = self.original() - maxInfluenced = self.maxInfluenced() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.MaxInfluences ) - op.parameters()['maxInfluences'].setValue( 2 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), maxInfluenced.influenceNames() ) - self.assertEqual( result.influencePose(), maxInfluenced.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), maxInfluenced.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), maxInfluenced.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), maxInfluenced.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), maxInfluenced.pointInfluenceWeights() ) - self.assertEqual( result, maxInfluenced ) - - def testMaxInfluencesModeWithLocks( self ) : - """ Test LimitSmoothSkinningInfluencesOp locking mechanism in max influences mode""" - - ssd = self.original() - maxInfluenced = self.maxInfluencedWithLocks() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.MaxInfluences ) - op.parameters()['maxInfluences'].setValue( 1 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, False ] ) ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), maxInfluenced.influenceNames() ) - self.assertEqual( result.influencePose(), maxInfluenced.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), maxInfluenced.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), maxInfluenced.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), maxInfluenced.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), maxInfluenced.pointInfluenceWeights() ) - self.assertEqual( result, maxInfluenced ) - - # make sure locked weights did not change - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - if resultIndices[i] == 0 : - self.assertAlmostEqual( resultWeights[i], origWeights[i], 6 ) - - def testMaxInfluencesModeAllLocked( self ) : - """ Test LimitSmoothSkinningInfluencesOp locking mechanism in max influences mode with all influences locked""" - - ssd = self.original() - maxInfluenced = self.maxInfluencedWithLocks() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.MaxInfluences ) - op.parameters()['maxInfluences'].setValue( 1 ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, True, True ] ) ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testIndexedMode( self ) : - """ Test LimitSmoothSkinningInfluencesOp in indexed mode""" - - ssd = self.original() - indexed = self.indexed() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.Indexed ) - op.parameters()['influenceIndices'].setFrameListValue( IECore.FrameList.parse( "0-2x2" ) ) - op.parameters()['compressResult'].setTypedValue( False ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), indexed.influenceNames() ) - self.assertEqual( result.influencePose(), indexed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), indexed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), indexed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), indexed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), indexed.pointInfluenceWeights() ) - self.assertEqual( result, indexed ) - - def testCompressionParameter( self ) : - """ Test LimitSmoothSkinningInfluencesOp in indexed mode with compression on""" - - ssd = self.original() - compressedAfterIndexed = self.compressedAfterIndexed() - - op = IECoreScene.LimitSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mode'].setValue( IECoreScene.LimitSmoothSkinningInfluencesOp.Mode.Indexed ) - op.parameters()['influenceIndices'].setFrameListValue( IECore.FrameList.parse( "1" ) ) - op.parameters()['compressResult'].setTypedValue( True ) - op.parameters()['applyLocks'].setValue( False ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), compressedAfterIndexed.influenceNames() ) - self.assertEqual( result.influencePose(), compressedAfterIndexed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), compressedAfterIndexed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), compressedAfterIndexed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), compressedAfterIndexed.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), compressedAfterIndexed.pointInfluenceWeights() ) - self.assertEqual( result, compressedAfterIndexed ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py b/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py deleted file mode 100644 index cd609493d2..0000000000 --- a/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py +++ /dev/null @@ -1,328 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class MixSmoothSkinningWeightsOpTest( unittest.TestCase ) : - - def createSSD( self, weights ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - offsets = IECore.IntVectorData( [0, 2, 5, 6] ) - counts = IECore.IntVectorData( [2, 3, 1, 2] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.2, 0.1, 1.2, 0.8] ) - - return self.createSSD( weights ) - - def toMix( self ) : - - weights = IECore.FloatVectorData( [0.5, 0.5, 0.25, 0.75, 0.2, 1.0, 0.6, 0.4] ) - - return self.createSSD( weights ) - - def mixed50_50_50( self ) : - - weights = IECore.FloatVectorData( [0.6, 0.6, 0.225, 0.675, 0.2, 0.55, 0.9, 0.6] ) - - return self.createSSD( weights ) - - def mixed75_75_75( self ) : - - weights = IECore.FloatVectorData( [0.65, 0.65, 0.2125, 0.6375, 0.2, 0.325, 1.05, 0.7] ) - - return self.createSSD( weights ) - - def mixed40_60_80( self ) : - - weights = IECore.FloatVectorData( [0.58, 0.62, 0.23, 0.66, 0.2, 0.46, 0.96, 0.72] ) - - return self.createSSD( weights ) - - def mixed0_50_100( self ) : - - weights = IECore.FloatVectorData( [0.5, 0.6, 0.25, 0.675, 0.2, 0.55, 0.9, 0.8] ) - - return self.createSSD( weights ) - - def testTypes( self ) : - """ Test MixSmoothSkinningWeightsOp types""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - self.assertEqual( type(op), IECoreScene.MixSmoothSkinningWeightsOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.MixSmoothSkinningWeightsOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testSelfMixing( self ) : - """ Test MixSmoothSkinningWeightsOp by mixing with itself""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( ssd ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5 ] ) ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testMix50_50_50( self ) : - """ Test MixSmoothSkinningWeightsOp with a 50-50 split between all weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - mixed = self.mixed50_50_50() - - self.assertEqual( result.influenceNames(), mixed.influenceNames() ) - self.assertEqual( result.influencePose(), mixed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), mixed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), mixed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), mixed.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = mixed.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testMix75_75_75( self ) : - """ Test MixSmoothSkinningWeightsOp with a 75-25 split between all weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.75, 0.75, 0.75 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - mixed = self.mixed75_75_75() - - self.assertEqual( result.influenceNames(), mixed.influenceNames() ) - self.assertEqual( result.influencePose(), mixed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), mixed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), mixed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), mixed.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = mixed.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testMix40_60_80( self ) : - """ Test MixSmoothSkinningWeightsOp with a mixed split between all weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.4, 0.6, 0.8 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - mixed = self.mixed40_60_80() - - self.assertEqual( result.influenceNames(), mixed.influenceNames() ) - self.assertEqual( result.influencePose(), mixed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), mixed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), mixed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), mixed.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = mixed.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testLockedInput( self ) : - """ Test MixSmoothSkinningWeightsOp with locked input weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 1, 1, 1 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = ssd.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testLockedMixingData( self ) : - """ Test MixSmoothSkinningWeightsOp with locked mixing weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0, 0, 0 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - mixed = self.toMix() - - self.assertEqual( result.influenceNames(), mixed.influenceNames() ) - self.assertEqual( result.influencePose(), mixed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), mixed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), mixed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), mixed.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = mixed.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testMix0_50_100( self ) : - """ Test MixSmoothSkinningWeightsOp with some mixed and some locked weights""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0, 0.5, 1 ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - mixed = self.mixed0_50_100() - - self.assertEqual( result.influenceNames(), mixed.influenceNames() ) - self.assertEqual( result.influencePose(), mixed.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), mixed.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), mixed.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), mixed.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - mixedWeights = mixed.pointInfluenceWeights() - for i in range( 0, result.pointInfluenceWeights().size() ) : - self.assertAlmostEqual( resultWeights[i], mixedWeights[i], 6 ) - - def testErrorStates( self ) : - """ Test MixSmoothSkinningWeightsOp with the various error states""" - - ssd = self.original() - - op = IECoreScene.MixSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - - # no data to mix - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of mixing weights - op.parameters()['skinningDataToMix'].setValue( self.toMix() ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5, 0.5 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of influences - bad = IECoreScene.SmoothSkinningData( IECore.StringVectorData( [ 'jointA', 'jointB' ] ), ssd.influencePose(), ssd.pointIndexOffsets(), ssd.pointInfluenceCounts(), ssd.pointInfluenceIndices(), ssd.pointInfluenceWeights() ) - op.parameters()['skinningDataToMix'].setValue( bad ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - bad = IECoreScene.SmoothSkinningData( IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC', 'jointD' ] ), ssd.influencePose(), ssd.pointIndexOffsets(), ssd.pointInfluenceCounts(), ssd.pointInfluenceIndices(), ssd.pointInfluenceWeights() ) - op.parameters()['skinningDataToMix'].setValue( bad ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of points - bad = IECoreScene.SmoothSkinningData( ssd.influenceNames(), ssd.influencePose(), IECore.IntVectorData( [0, 2, 5, 6, 8] ), ssd.pointInfluenceCounts(), ssd.pointInfluenceIndices(), ssd.pointInfluenceWeights() ) - op.parameters()['skinningDataToMix'].setValue( bad ) - op.parameters()['mixingWeights'].setValue( IECore.FloatVectorData( [ 0.5, 0.5, 0.5 ] ) ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py b/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py deleted file mode 100644 index 2991747d1b..0000000000 --- a/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py +++ /dev/null @@ -1,171 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class NormalizeSmoothSkinningWeightsOpTest( unittest.TestCase ) : - - def createSSD( self, weights ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - offsets = IECore.IntVectorData( [0, 2, 5, 6] ) - counts = IECore.IntVectorData( [2, 3, 1, 2] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.7, 0.2, 0.6, 0.0, 0.1, 1.2, 0.8] ) - - return self.createSSD( weights ) - - def normalized( self ) : - - weights = IECore.FloatVectorData( [0.5, 0.5, 0.25, 0.75, 0.0, 1.0, 0.6, 0.4] ) - - return self.createSSD( weights ) - - def normalizedWithLocks( self ) : - - weights = IECore.FloatVectorData( [0.7, 0.3, 0.2, 0.8, 0.0, 1.0, 0.6, 0.4] ) - - return self.createSSD( weights ) - - def testTypes( self ) : - """ Test NormalizeSmoothSkinningWeightsOp types""" - - ssd = self.original() - - op = IECoreScene.NormalizeSmoothSkinningWeightsOp() - self.assertEqual( type(op), IECoreScene.NormalizeSmoothSkinningWeightsOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.NormalizeSmoothSkinningWeightsOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testNormalizingNormalized( self ) : - """ Test NormalizeSmoothSkinningWeightsOp with weights which are already normalized""" - - ssd = self.normalized() - - op = IECoreScene.NormalizeSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testNormalizingUnnormalized( self ) : - """ Test NormalizeSmoothSkinningWeightsOp with unnormalized weights""" - - ssd = self.original() - - op = IECoreScene.NormalizeSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - normalized = self.normalized() - - self.assertEqual( result.influenceNames(), normalized.influenceNames() ) - self.assertEqual( result.influencePose(), normalized.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), normalized.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), normalized.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), normalized.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), normalized.pointInfluenceWeights() ) - self.assertEqual( result, normalized ) - - def testLocks( self ) : - """ Test NormalizeSmoothSkinningWeightsOp locking mechanism""" - - ssd = self.original() - - op = IECoreScene.NormalizeSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, False ] ) ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - normalized = self.normalizedWithLocks() - - self.assertEqual( result.influenceNames(), normalized.influenceNames() ) - self.assertEqual( result.influencePose(), normalized.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), normalized.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), normalized.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), normalized.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), normalized.pointInfluenceWeights() ) - self.assertEqual( result, normalized ) - - # make sure locked weights did not change - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - if resultIndices[i] == 0 : - self.assertEqual( resultWeights[i], origWeights[i] ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/PointSmoothSkinningOpTest.py b/test/IECoreScene/PointSmoothSkinningOpTest.py deleted file mode 100644 index 06e9fee79a..0000000000 --- a/test/IECoreScene/PointSmoothSkinningOpTest.py +++ /dev/null @@ -1,225 +0,0 @@ -########################################################################## -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import unittest -import imath -import IECore -import IECoreScene - - -class PointSmoothSkinningOpTest( unittest.TestCase ) : - - def mySSD (self): - # return an ssd for testing - ok_jn = IECore.StringVectorData( [ 'joint1', 'joint2', 'joint3' ] ) - ok_ip = IECore.M44fVectorData( [imath.M44f().translate(imath.V3f(0,2,0)), imath.M44f(), imath.M44f().translate(imath.V3f(0,-2,0))] ) - ok_pio = IECore.IntVectorData( [0, 2, 4, 6, 8, 10, 12, 14] ) - ok_pic = IECore.IntVectorData( [2, 2, 2, 2, 2, 2, 2, 2] ) - ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1] ) - ok_piw = IECore.FloatVectorData( [1, 0, 1, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0, 1, 0] ) - ssd = IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, ok_pii, ok_piw) - ssd.validate() - return ssd - - def myN (self): - # return an n for testing - n = IECore.V3fVectorData( [ imath.V3f(0, -1, 0), imath.V3f(0, -1, 0 ), imath.V3f(0, 1, 0 ), imath.V3f(0, 1, 0 ), - imath.V3f(0, 1, 0 ), imath.V3f(0, 1, 0 ), imath.V3f(0, -1, 0), imath.V3f(0, -1, 0)] ) - return n - - def myP (self): - # return an p for testing - p = IECore.V3fVectorData( [ imath.V3f(-0.5, -2, 0.5), imath.V3f(0.5, -2, 0.5 ), imath.V3f(-0.5, 2, 0.5 ), imath.V3f(0.5, 2, 0.5 ), - imath.V3f(-0.5, 2, -0.5), imath.V3f(0.5, 2, -0.5 ), imath.V3f(-0.5, -2, -0.5), imath.V3f(0.5, -2, -0.5)] ) - return p - - def myPP (self): - # return a point primitive for testing - pts = IECoreScene.PointsPrimitive( self.myP() ) - vertex = IECoreScene.PrimitiveVariable.Interpolation.Vertex - pts["N"] = IECoreScene.PrimitiveVariable( vertex, self.myN() ) - self.assertTrue( pts.arePrimitiveVariablesValid() ) - return pts - - def myMN (self): - # face varying n - n = IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), - imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), - imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), - imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), - imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), - imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ) ] ) - return n - - def myMP (self): - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ 0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4 ] ) - m = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds, "catmullClark" ) - m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, self.myP() ) - m["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, self.myMN() ) - self.assertTrue( m.arePrimitiveVariablesValid() ) - return m - - def myDP (self): - # return a deformation pose for testing (2nd joint roated by 90deg in z) - dp = IECore.M44fVectorData( [ imath.M44f( 1, 0, 0, 0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ), - imath.M44f( 0, 1, 0, -0, -1, 0, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - imath.M44f( 0, 1, 0, 0, -1, 0, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) ] ) - return dp - - - def testNoArg( self ) : - # check calling with no arguments - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o ) - - def testDeformation( self ) : - # check that it deforms P and N as expected - pts = self.myPP() - - o = IECoreScene.PointSmoothSkinningOp() - o( input = pts, copyInput=False, deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals=True) - self.assertNotEqual(pts["P"].data , self.myP()) - self.assertNotEqual(pts["N"].data , self.myN()) - - #test a sample p was deformed as expexted - #print pts["P"].data - #self.assertNotEqual(pts["P"].data[2] , V3f((1, -0.5, 0.5) )) - #test a sample n was deformed as expected - #self.assertNotEqual(pts["N"].data[2] , V3f( (1, -0.5, 0.5) )) - - def testMissingP( self ) : - # check not passing p is a passthru - pts = IECoreScene.PointsPrimitive(0) - vertex = IECoreScene.PrimitiveVariable.Interpolation.Vertex - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - deformationPose = self.myDP(), smoothSkinningData = self.mySSD() ) - - def testMissingN( self ) : - pts = IECoreScene.PointsPrimitive(0) - vertex = IECoreScene.PrimitiveVariable.Interpolation.Vertex - pts["P"] = IECoreScene.PrimitiveVariable( vertex, self.myP() ) - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals = True ) - - def testMissingSSD( self ) : - # test if the ssd is missing - pts = self.myPP() - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - deformationPose = self.myDP() ) - - def testMissingDeformationPose( self ) : - # test if the def pose is missing - pts = self.myPP() - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - smoothSkinningData = self.mySSD()) -# - def testBadSSD( self ) : - pts = self.myPP() - o = IECoreScene.PointSmoothSkinningOp() - - # test if the ssd is not matching the deformationPose - ssd = self.mySSD() - a = ssd.influencePose() - a.append(imath.M44f()) - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - smoothSkinningData = ssd, deformationPose = self.myDP()) - - # test if the ssd is not matching the p - ssd = self.mySSD() - a = ssd.pointInfluenceCounts() - a.append(2) - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - smoothSkinningData = ssd,deformationPose = self.myDP()) - - # test for bad ssd - ssd = self.mySSD() - a = ssd.influenceNames() - a.append("bob") - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - smoothSkinningData = ssd,deformationPose = self.myDP()) - - def testBadDeformationPose( self ) : - pts = self.myPP() - o = IECoreScene.PointSmoothSkinningOp() - - # test if the ssd is not matching the deformationPose - dp = self.myDP() - dp.append(imath.M44f()) - - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - smoothSkinningData = self.mySSD(), deformationPose = dp) - - def testPrimVarLengthMismatch( self ) : - # check that len(p)!=len(n) raises exception - pts = IECoreScene.PointsPrimitive(0) - vertex = IECoreScene.PrimitiveVariable.Interpolation.Vertex - pts["P"] = IECoreScene.PrimitiveVariable( vertex, self.myP() ) - pts["N"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(0, -1, 0)] ) ) - o = IECoreScene.PointSmoothSkinningOp() - self.assertRaises( RuntimeError, o, input=pts, copyInput=True, - deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals = True ) - - def testOtherPrimitives( self ) : - # check that it works with other primitives, meshPrim - mp = self.myMP() - o = IECoreScene.PointSmoothSkinningOp() - # test it works - o( input=mp, copyInput=False, deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals = False ) - self.assertNotEqual(mp["P"].data , self.myP()) - self.assertEqual(mp["N"].data , self.myMN()) - - o( input=mp, copyInput=False, deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals = True ) - self.assertNotEqual(mp["P"].data , self.myP()) - self.assertNotEqual(mp["N"].data , self.myMN()) - - - def testDifferentVarNames( self ) : - # check using different var names - pts = self.myPP() - o = IECoreScene.PointSmoothSkinningOp() - pts['bob'] = pts['P'] - del pts['P'] - self.assertEqual( len(pts.keys()), 2 ) - o(input=pts, positionVar="bob", copyInput=False, deformationPose = self.myDP(), smoothSkinningData = self.mySSD( )) - self.assertNotEqual(pts["bob"].data , self.myP()) - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py deleted file mode 100644 index ca8b9905fc..0000000000 --- a/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py +++ /dev/null @@ -1,157 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class ReorderSmoothSkinningInfluencesOpTest( unittest.TestCase ) : - - def createSSD( self, names, poses, indices ) : - - offsets = IECore.IntVectorData( [0, 2, 5] ) - counts = IECore.IntVectorData( [2, 3, 1] ) - weights = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 0.0, 1.0] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1] ) - - return self.createSSD( names, poses, indices ) - - def reordered( self ) : - - names = IECore.StringVectorData( [ 'jointB', 'jointC', 'jointA' ] ) - poses = IECore.M44fVectorData( [imath.M44f(2),imath.M44f(3),imath.M44f(1)] ) - indices = IECore.IntVectorData( [2, 0, 2, 0, 1, 0] ) - - return self.createSSD( names, poses, indices ) - - def testTypes( self ) : - """ Test ReorderSmoothSkinningInfluencesOp types""" - - ssd = self.original() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - self.assertEqual( type(op), IECoreScene.ReorderSmoothSkinningInfluencesOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.ReorderSmoothSkinningInfluencesOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testSameNames( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with same names""" - - ssd = self.original() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['reorderedInfluenceNames'].setValue( ssd.influenceNames() ) - result = op.operate() - - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testReordering( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with reordered names""" - - ssd = self.original() - reordered = self.reordered() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['reorderedInfluenceNames'].setValue( reordered.influenceNames() ) - result = op.operate() - self.assertNotEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertNotEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), reordered.influenceNames() ) - self.assertEqual( result.influencePose(), reordered.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), reordered.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), reordered.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), reordered.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), reordered.pointInfluenceWeights() ) - self.assertEqual( result, reordered ) - - def testWrongNames( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with wrong names""" - - ssd = self.original() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['reorderedInfluenceNames'].setValue( IECore.StringVectorData( [ 'jointA', 'badName', 'jointC' ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - def testExtraNames( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with extra names""" - - ssd = self.original() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['reorderedInfluenceNames'].setValue( IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC', 'jointD' ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - def testNoNames( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with no new names""" - - ssd = self.original() - - op = IECoreScene.ReorderSmoothSkinningInfluencesOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['reorderedInfluenceNames'].setValue( IECore.StringVectorData([]) ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/SmoothSkinningDataTest.py b/test/IECoreScene/SmoothSkinningDataTest.py deleted file mode 100644 index c448c1df39..0000000000 --- a/test/IECoreScene/SmoothSkinningDataTest.py +++ /dev/null @@ -1,170 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -# -# Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), -# its affiliates and/or its licensors. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -"""Unit test for SmoothSkinningData binding""" -import imath - -import IECore -import IECoreScene - -import os -import unittest - -class TestSmoothSkinningData( unittest.TestCase ) : - - def testData( self ) : - # test the object - s = IECoreScene.SmoothSkinningData() - self.assertEqual( s.influenceNames(), IECore.StringVectorData() ) - self.assertEqual( s.influencePose(), IECore.M44fVectorData() ) - self.assertEqual( s.pointIndexOffsets(), IECore.IntVectorData() ) - self.assertEqual( s.pointInfluenceCounts(), IECore.IntVectorData() ) - self.assertEqual( s.pointInfluenceIndices(), IECore.IntVectorData() ) - self.assertEqual( s.pointInfluenceWeights(), IECore.FloatVectorData() ) - self.assertEqual( s, s ) - self.assertEqual( s, s.copy() ) - self.assertEqual( s, IECoreScene.SmoothSkinningData() ) - - def testIO( self ) : - # test fileIndexedIO, read and write - ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) - ok_pio = IECore.IntVectorData( [0, 2, 4] ) - ok_pic = IECore.IntVectorData( [2, 2, 1] ) - ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) - ok_piw = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 1.0] ) - - s = IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, ok_pii, ok_piw) - iface = IECore.IndexedIO.create( os.path.join( "test", "IECore", "ssd.fio" ), IECore.IndexedIO.OpenMode.Write ) - - s.save( iface, "test" ) - ss = IECore.Object.load( iface, "test" ) - self.assertEqual( s, ss ) - - def testDataStorage(self ): - #test the object can store data - ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) - ok_pio = IECore.IntVectorData( [0, 2, 4] ) - ok_pic = IECore.IntVectorData( [2, 2, 1] ) - ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) - ok_piw = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 1.0] ) - s = IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, ok_pii, ok_piw) - - self.assertEqual( s.influenceNames() , ok_jn ) - self.assertEqual( s.influencePose() , ok_ip ) - self.assertEqual( s.pointIndexOffsets() , ok_pio ) - self.assertEqual( s.pointInfluenceCounts() , ok_pic ) - self.assertEqual( s.pointInfluenceIndices() , ok_pii ) - self.assertEqual( s.pointInfluenceWeights() , ok_piw ) - - self.assertEqual( s, s ) - self.assertEqual( s, s.copy() ) - - iface = IECore.IndexedIO.create( os.path.join( "test", "IECore", "ssd.fio" ), IECore.IndexedIO.OpenMode.Write ) - s.save( iface, "test" ) - ss = IECore.Object.load( iface, "test" ) - self.assertEqual( s, ss ) - - def testValidate(self): - - # good data - ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) - ok_pio = IECore.IntVectorData( [0, 2, 4] ) - ok_pic = IECore.IntVectorData( [2, 2, 1] ) - ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) - ok_piw = IECore.FloatVectorData( [0.5, 0.5, 0.2, 0.8, 1.0] ) - - # data with invalid nr of elements - iv_jn = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - iv_ip = IECore.M44fVectorData( [imath.M44f()] ) - iv_pio1 = IECore.IntVectorData( [0, 2, 4, 666] ) - iv_pic1 = IECore.IntVectorData( [2, 2 ] ) - iv_pii1 = IECore.IntVectorData( [0, 1, 0, 1, 1, 666] ) - iv_piw = IECore.FloatVectorData( [0.5, 0.5, 0.2] ) - - # data with invalid ids - iv_pio2 = IECore.IntVectorData( [0, 2, 666] ) - iv_pii2 = IECore.IntVectorData( [0, 1, 666, 1, 1] ) - - # data with invalid counts - iv_pic2 = IECore.IntVectorData( [2, 0, 1 ] ) - - # data with count / index mismatch - iv_pio3 = IECore.IntVectorData( [0, 3, 4] ) - iv_pic3 = IECore.IntVectorData( [3, 1, 1] ) - - # test all is ok - IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, ok_pii, ok_piw).validate() - - # test wrong nr of influenceNames, influencePose - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(iv_jn, ok_ip, ok_pio, ok_pic, ok_pii, ok_piw).validate ) - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, iv_ip, ok_pio, ok_pic, ok_pii, ok_piw).validate ) - - # test wrong nr of pointIndexOffsets, pointInfluenceCounts - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, iv_pio1, ok_pic, ok_pii, ok_piw).validate ) - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, iv_pic1, ok_pii, ok_piw).validate ) - - # test wrong nr of pointInfluenceIndices, pointInfluenceWeights - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, iv_pii1, ok_piw).validate ) - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, ok_pii, iv_piw).validate ) - - # test invalid ids - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, iv_pio2, ok_pic, ok_pii, ok_piw).validate ) - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, ok_pic, iv_pii2, ok_piw).validate ) - - # test wrong counts - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, iv_pic2, ok_pii, ok_piw).validate ) - - # test count id mismatching - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, iv_pio3, ok_pic, ok_pii, ok_piw).validate ) - self.assertRaises( Exception, IECoreScene.SmoothSkinningData(ok_jn, ok_ip, ok_pio, iv_pic3, ok_pii, ok_piw).validate ) - -# todo: add reference test data we are happy with -# def testRef(self): -# load reference data we are sure is cool -# ss = Reader.create( "test/IECore/data/cobFiles/smoothSkinningData.cob" ).read() -# self.assertTrue( ss.isValid() ); - - def tearDown( self ) : - - if os.path.isfile(os.path.join( "test", "IECore", "ssd.fio" )): - os.remove(os.path.join( "test", "IECore", "ssd.fio" )) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py b/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py deleted file mode 100644 index c7820566ac..0000000000 --- a/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py +++ /dev/null @@ -1,433 +0,0 @@ -########################################################################## -# -# Copyright (c) 2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class SmoothSmoothSkinningWeightsOpTest( unittest.TestCase ) : - - def mesh( self ) : - - vertsPerFace = IECore.IntVectorData( [ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ] ) - vertexIds = IECore.IntVectorData( [ - 0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, - 8, 9, 11, 10, 10, 11, 13, 12, 12, 13, 15, 14, 14, 15, 1, 0, - 1, 15, 13, 3, 3, 13, 11, 5, 5, 11, 9, 7, 14, 0, 2, 12, - 12, 2, 4, 10, 10, 4, 6, 8 - ] ) - - return IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) - - def createSSD( self, offsets, counts, indices, weights ) : - - names = IECore.StringVectorData( [ "|joint1", "|joint1|joint2", "|joint1|joint2|joint3" ] ) - poses = IECore.M44fVectorData( [ - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) - ] ) - - return IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - def original( self ) : - - offsets = IECore.IntVectorData( [ 0, 1, 2, 4, 6, 7, 8, 10, 12, 14, 16, 17, 18, 20, 22, 23 ] ) - counts = IECore.IntVectorData( [ 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1 ] ) - indices = IECore.IntVectorData( [ 0, 0, 0, 1, 0, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 0 ] ) - - weights = IECore.FloatVectorData( [ - 1, 1, 0.8, 0.2, 0.8, 0.2, 1, 1, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 1, 1, 0.8, 0.2, 0.8, 0.2, 1, 1 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def smooth1_50( self ) : - - offsets = IECore.IntVectorData( [ 0, 2, 4, 6, 8, 11, 14, 16, 18, 20, 22, 25, 28, 30, 32, 34 ] ) - counts = IECore.IntVectorData( [ 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2 ] ) - indices = IECore.IntVectorData( [ - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1 - ] ) - - weights = IECore.FloatVectorData( [ - 0.966667, 0.0333333, 0.966667, 0.0333333, 0.725, 0.275, 0.725, 0.275, - 0.1, 0.8375, 0.0625, 0.1, 0.8375, 0.0625, 0.583333, 0.416667, - 0.583333, 0.416667, 0.583333, 0.416667, 0.583333, 0.416667, 0.1, 0.8375, - 0.0625, 0.1, 0.8375, 0.0625, 0.725, 0.275, 0.725, 0.275, - 0.966667, 0.0333333, 0.966667, 0.0333333 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def smooth1_100( self ) : - - offsets = IECore.IntVectorData( [ 0, 2, 4, 6, 8, 11, 14, 16, 18, 20, 22, 25, 28, 30, 32, 34 ] ) - counts = IECore.IntVectorData( [ 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2 ] ) - indices = IECore.IntVectorData( [ - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1 - ] ) - - weights = IECore.FloatVectorData( [ - 0.933333, 0.0666667, 0.933333, 0.0666667, 0.65, 0.35, 0.65, 0.35, - 0.2, 0.675, 0.125, 0.2, 0.675, 0.125, 0.666667, 0.333333, - 0.666667, 0.333333, 0.666667, 0.333333, 0.666667, 0.333333, 0.2, 0.675, - 0.125, 0.2, 0.675, 0.125, 0.65, 0.35, 0.65, 0.35, - 0.933333, 0.0666667, 0.933333, 0.0666667 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def smooth3_30( self ) : - - offsets = IECore.IntVectorData( [ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45 ] ) - counts = IECore.IntVectorData( [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ] ) - indices = IECore.IntVectorData( [ - 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, - 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2 - ] ) - - weights = IECore.FloatVectorData( [ - 0.933725, 0.0659938, 0.00028125, 0.933725, 0.0659938, 0.00028125, 0.691672, 0.301016, - 0.0073125, 0.691672, 0.301016, 0.0073125, 0.145912, 0.767439, 0.0866484, 0.145912, - 0.767439, 0.0866484, 0.0161625, 0.6094, 0.374438, 0.0161625, 0.6094, 0.374438, - 0.0161625, 0.6094, 0.374438, 0.0161625, 0.6094, 0.374438, 0.145912, 0.767439, - 0.0866484, 0.145912, 0.767439, 0.0866484, 0.691672, 0.301016, 0.0073125, 0.691672, - 0.301016, 0.0073125, 0.933725, 0.0659938, 0.00028125, 0.933725, 0.0659938, 0.00028125 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def smoothSelectVerts( self ) : - - offsets = IECore.IntVectorData( [ 0, 1, 2, 4, 6, 9, 10, 12, 14, 16, 18, 21, 24, 26, 28, 29 ] ) - counts = IECore.IntVectorData( [ 1, 1, 2, 2, 3, 1, 2, 2, 2, 2, 3, 3, 2, 2, 1, 1 ] ) - indices = IECore.IntVectorData( [ - 0, 0, 0, 1, 0, 1, 0, 1, 2, 1, 1, 2, 1, 2, 1, 2, - 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, 0 - ] ) - - weights = IECore.FloatVectorData( [ - 1, 1, 0.725, 0.275, 0.725, 0.275, 0.1, 0.8375, 0.0625, - 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.1, - 0.8375, 0.0625, 0.1, 0.8375, 0.0625, 0.725, 0.275, 0.8, 0.2, 1, 1 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def smoothWithLocks( self ) : - - offsets = IECore.IntVectorData( [ 0, 1, 2, 5, 8, 10, 12, 14, 16, 18, 20, 22, 24, 27, 30, 31 ] ) - counts = IECore.IntVectorData( [ 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1 ] ) - indices = IECore.IntVectorData( [ - 0, 0, 0, 1, 2, 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 2, 0, 1, 2, 0, 0 - ] ) - - weights = IECore.FloatVectorData( [ - 1, 1, 0.8, 0.193898, 0.00610161, 0.8, 0.193898, 0.00610161, - 0.902086, 0.0979137, 0.902086, 0.0979137, 0.624712, 0.375288, 0.624712, 0.375288, - 0.624712, 0.375288, 0.624712, 0.375288, 0.902086, 0.0979137, 0.902086, 0.0979137, - 0.8, 0.193898, 0.00610161, 0.8, 0.193898, 0.00610161, 1, 1 - ] ) - - return self.createSSD( offsets, counts, indices, weights ) - - def testTypes( self ) : - """ Test SmoothSmoothSkinningWeightsOp types""" - - ssd = self.original() - - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - self.assertEqual( type(op), IECoreScene.SmoothSmoothSkinningWeightsOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.SmoothSmoothSkinningWeightsOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testSmooth1_0( self ) : - """ Test SmoothSmoothSkinningWeightsOp with 1 iteration and 0.0 smooth-ratio""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 0.0 ) - op.parameters()['iterations'].setValue( 1 ) - op.parameters()['applyLocks'].setValue( False ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertEqual( result, ssd ) - - def testSmooth1_100( self ) : - """ Test SmoothSmoothSkinningWeightsOp with 1 iteration and 1.0 smooth-ratio""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 1.0 ) - op.parameters()['iterations'].setValue( 1 ) - op.parameters()['applyLocks'].setValue( False ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - smooth = self.smooth1_100() - self.assertEqual( result.influenceNames(), smooth.influenceNames() ) - self.assertEqual( result.influencePose(), smooth.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), smooth.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), smooth.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), smooth.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - smoothWeights = smooth.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], smoothWeights[i], 6 ) - - def testSmooth1_50( self ) : - """ Test SmoothSmoothSkinningWeightsOp with 1 iteration and 0.5 smooth-ratio""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 0.5 ) - op.parameters()['iterations'].setValue( 1 ) - op.parameters()['applyLocks'].setValue( False ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - smooth = self.smooth1_50() - self.assertEqual( result.influenceNames(), smooth.influenceNames() ) - self.assertEqual( result.influencePose(), smooth.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), smooth.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), smooth.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), smooth.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - smoothWeights = smooth.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], smoothWeights[i], 6 ) - - def testSmooth3_30( self ) : - """ Test SmoothSmoothSkinningWeightsOp with 3 iterations and 0.3 smooth-ratio""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 0.3 ) - op.parameters()['iterations'].setValue( 3 ) - op.parameters()['applyLocks'].setValue( False ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - smooth = self.smooth3_30() - self.assertEqual( result.influenceNames(), smooth.influenceNames() ) - self.assertEqual( result.influencePose(), smooth.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), smooth.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), smooth.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), smooth.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - smoothWeights = smooth.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], smoothWeights[i], 6 ) - - def testLocks( self ) : - """ Test SmoothSmoothSkinningWeightsOp locking mechanism""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 0.3 ) - op.parameters()['iterations'].setValue( 3 ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, False ] ) ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - smooth = self.smoothWithLocks() - self.assertEqual( result.influenceNames(), smooth.influenceNames() ) - self.assertEqual( result.influencePose(), smooth.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), smooth.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), smooth.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), smooth.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - smoothWeights = smooth.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], smoothWeights[i], 6 ) - - # make sure locked weights did not change - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - if resultIndices[i] == 0 : - self.assertAlmostEqual( resultWeights[i], origWeights[i], 6 ) - - # make sure the result is normalized - nop = IECoreScene.NormalizeSmoothSkinningWeightsOp() - nop.parameters()['input'].setValue( result ) - normalized = nop.operate() - self.assertEqual( result.influenceNames(), normalized.influenceNames() ) - self.assertEqual( result.influencePose(), normalized.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), normalized.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), normalized.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), normalized.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - normalizedWeights = normalized.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], normalizedWeights[i], 6 ) - - def testVertexSelection( self ) : - """ Test SmoothSmoothSkinningWeightsOp using selected vertices""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['smoothingRatio'].setValue( 0.5 ) - op.parameters()['iterations'].setValue( 1 ) - op.parameters()['applyLocks'].setValue( False ) - op.parameters()['vertexIndices'].setFrameListValue( IECore.FrameList.parse( "2-4,10-12" ) ) - - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - smooth = self.smoothSelectVerts() - self.assertEqual( result.influenceNames(), smooth.influenceNames() ) - self.assertEqual( result.influencePose(), smooth.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), smooth.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), smooth.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), smooth.pointInfluenceIndices() ) - resultWeights = result.pointInfluenceWeights() - smoothWeights = smooth.pointInfluenceWeights() - for i in range( 0, resultWeights.size() ) : - self.assertAlmostEqual( resultWeights[i], smoothWeights[i], 6 ) - - # make sure only selected vertices changed - dop = IECoreScene.DecompressSmoothSkinningDataOp() - dop.parameters()['input'].setValue( result ) - decompressedResult = dop.operate() - dop.parameters()['input'].setValue( ssd ) - decompressedOrig = dop.operate() - resultOffsets = decompressedResult.pointIndexOffsets() - resultCounts = decompressedResult.pointInfluenceCounts() - resultIndices = decompressedResult.pointInfluenceIndices() - resultWeights = decompressedResult.pointInfluenceWeights() - origWeights = decompressedOrig.pointInfluenceWeights() - nonSelectedVerts = [ x for x in range( 0, resultOffsets.size() ) if x not in op.parameters()['vertexIndices'].getFrameListValue().asList() ] - for i in nonSelectedVerts : - for j in range( 0, resultCounts[i] ) : - current = resultOffsets[i] + j - self.assertAlmostEqual( resultWeights[current], origWeights[current], 6 ) - - def testErrorStates( self ) : - """ Test SmoothSmoothSkinningWeightsOp with various error states""" - - ssd = self.original() - op = IECoreScene.SmoothSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - - # bad mesh - op.parameters()['mesh'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of verts - op.parameters()['mesh'].setValue( op.parameters()['mesh'].defaultValue ) - self.assertRaises( RuntimeError, op.operate ) - - # wrong number of locks - op.parameters()['mesh'].setValue( self.mesh() ) - op.parameters()['applyLocks'].setValue( True ) - op.parameters()['influenceLocks'].setValue( IECore.BoolVectorData( [ True, False, True, False ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - # invalid vertex ids - op.parameters()['applyLocks'].setValue( False ) - op.parameters()['vertexIndices'].setFrameListValue( IECore.FrameList.parse( "10-18" ) ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main() diff --git a/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py b/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py deleted file mode 100644 index 225a3c06b6..0000000000 --- a/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py +++ /dev/null @@ -1,198 +0,0 @@ -########################################################################## -# -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import math -import unittest -import random -import imath -import IECore -import IECoreScene - - -class TransferSmoothSkinningWeightsOpTest( unittest.TestCase ) : - - def createSSD( self, weights, indices, offsets, counts ) : - - names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) - - ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) - - return ssd - - def original( self ) : - - weights = IECore.FloatVectorData( [0.1, 0.1, 0.1, 0.2, 0.2, 0.3] ) - indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1] ) - offsets = IECore.IntVectorData( [0, 2, 5] ) - counts = IECore.IntVectorData( [2, 3, 1] ) - - return self.createSSD( weights, indices, offsets, counts ) - - def transferredA( self ) : - - weights = IECore.FloatVectorData( [0.2, 0.3, 0.2, 0.3] ) - indices = IECore.IntVectorData( [1, 1, 2, 1] ) - offsets = IECore.IntVectorData( [0, 1, 3] ) - counts = IECore.IntVectorData( [1, 2, 1] ) - - return self.createSSD( weights, indices, offsets, counts ) - - def transferredAC( self ) : - - weights = IECore.FloatVectorData( [0.2, 0.5, 0.3] ) - indices = IECore.IntVectorData( [1, 1, 1] ) - offsets = IECore.IntVectorData( [0, 1, 2] ) - counts = IECore.IntVectorData( [1, 1, 1] ) - - return self.createSSD( weights, indices, offsets, counts ) - - def testTypes( self ) : - """ Test TransferSmoothSkinningWeightsOp types""" - - ssd = self.original() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - self.assertEqual( type(op), IECoreScene.TransferSmoothSkinningWeightsOp ) - self.assertEqual( op.typeId(), IECoreScene.TypeId.TransferSmoothSkinningWeightsOp ) - op.parameters()['input'].setValue( IECore.IntData(1) ) - self.assertRaises( RuntimeError, op.operate ) - - def testSameNames( self ) : - """ Test TransferSmoothSkinningWeightsOp with same names""" - - ssd = self.original() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData(["jointA"]) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("jointA") ) - self.assertRaises( RuntimeError, op.operate ) - - def testTransferredSingle( self ) : - """ Test TransferSmoothSkinningWeightsOp with one transferred influence""" - - ssd = self.original() - transferred = self.transferredA() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData(["jointA"]) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("jointB") ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), transferred.influenceNames() ) - self.assertEqual( result.influencePose(), transferred.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), transferred.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), transferred.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), transferred.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), transferred.pointInfluenceWeights() ) - self.assertEqual( result, transferred ) - - def testTransferredMultiple( self ) : - """ Test TransferSmoothSkinningWeightsOp with multiple transferred influences""" - - ssd = self.original() - transferred = self.transferredAC() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData(["jointA", "jointC"]) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("jointB") ) - result = op.operate() - self.assertEqual( result.influenceNames(), ssd.influenceNames() ) - self.assertEqual( result.influencePose(), ssd.influencePose() ) - self.assertNotEqual( result.pointInfluenceIndices(), ssd.pointInfluenceIndices() ) - self.assertNotEqual( result.pointIndexOffsets(), ssd.pointIndexOffsets() ) - self.assertNotEqual( result.pointInfluenceCounts(), ssd.pointInfluenceCounts() ) - self.assertNotEqual( result.pointInfluenceWeights(), ssd.pointInfluenceWeights() ) - self.assertNotEqual( result, ssd ) - - self.assertEqual( result.influenceNames(), transferred.influenceNames() ) - self.assertEqual( result.influencePose(), transferred.influencePose() ) - self.assertEqual( result.pointIndexOffsets(), transferred.pointIndexOffsets() ) - self.assertEqual( result.pointInfluenceCounts(), transferred.pointInfluenceCounts() ) - self.assertEqual( result.pointInfluenceIndices(), transferred.pointInfluenceIndices() ) - self.assertEqual( result.pointInfluenceWeights(), transferred.pointInfluenceWeights() ) - self.assertEqual( result, transferred ) - - def testWrongNames( self ) : - """ Test TransferSmoothSkinningWeightsOp with wrong names""" - - ssd = self.original() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData( [ 'jointA', 'badName', 'jointC' ] ) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringVectorData( [ 'jointB' ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData( [ 'jointA', 'jointB' ] ) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringVectorData( [ 'badName' ] ) ) - self.assertRaises( RuntimeError, op.operate ) - - def testNoNames( self ) : - """ Test ReorderSmoothSkinningInfluencesOp with no new names""" - - ssd = self.original() - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData([]) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("jointB") ) - self.assertRaises( RuntimeError, op.operate ) - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData(["jointA", ""]) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("jointB") ) - self.assertRaises( RuntimeError, op.operate ) - - op = IECoreScene.TransferSmoothSkinningWeightsOp() - op.parameters()['input'].setValue( ssd ) - op.parameters()['sourceInfluenceNames'].setValue( IECore.StringVectorData(['jointA', 'jointB']) ) - op.parameters()['targetInfluenceName'].setValue( IECore.StringData("") ) - self.assertRaises( RuntimeError, op.operate ) - -if __name__ == "__main__": - unittest.main()