Skip to content

Commit d0aed85

Browse files
committed
Merge branch 'RB-10.5'
2 parents 85f9bca + e644618 commit d0aed85

File tree

22 files changed

+519
-95
lines changed

22 files changed

+519
-95
lines changed

Changes

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
1-
10.5.x.x (relative to 10.5.4.1)
1+
10.5.x.x (relative to 10.5.6.0)
22
========
33

4+
10.5.6.0 (relative to 10.5.5.0)
5+
========
6+
7+
Improvements
8+
------------
9+
10+
- `IECoreGL::Selector`: Added constructor overload that accepts a boolean indicating a more precise, camera-space depth sample will be used to sample depth instead of OpenGL's depth buffer.
11+
- `IECoreGL::ColorTexture`: Added new constructor that accepts an argument specifying the internal storage format to use.
12+
13+
14+
15+
10.5.5.0 (relative to 10.5.4.2)
16+
========
17+
18+
Features
19+
--------
20+
21+
- PyBindConverter : Added new class providing interoperability between Boost Python bindings and PyBind11 bindings.
22+
23+
Improvements
24+
------------
25+
26+
- USDScene : Added basic loading of UsdGeomNurbsCurves, converting them to CurvesPrimitives.
27+
- OStreamMessageHandler : Added level prefix to every line.
28+
29+
Fixes
30+
-----
31+
32+
- CompoundObject : Fixed crashes in Python bindings caused by passing `None` as a key.
33+
- VDBObject : Fixed Python bindings for OpenVDB 10.1.
34+
35+
10.5.4.2 (relative to 10.5.4.1)
36+
========
37+
38+
Fixes
39+
-----
440

41+
- ExceptionAlgo : Fixed memory leak in `translatePythonException()`, which was failing to manage the reference count for exceptions bound by `IECorePython::ExceptionClass`.
542

643
10.5.4.1 (relative to 10.5.4.0)
744
========

SConstruct

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ SConsignFile()
5656

5757
ieCoreMilestoneVersion = 10 # for announcing major milestones - may contain all of the below
5858
ieCoreMajorVersion = 5 # backwards-incompatible changes
59-
ieCoreMinorVersion = 4 # new backwards-compatible features
60-
ieCorePatchVersion = 1 # bug fixes
59+
ieCoreMinorVersion = 6 # new backwards-compatible features
60+
ieCorePatchVersion = 0 # bug fixes
6161
ieCoreVersionSuffix = "" # used for alpha/beta releases. Example: "a1", "b2", etc.
6262

6363
###########################################################################################
@@ -967,6 +967,7 @@ o.Add(
967967
###########################################################################################
968968

969969
env = Environment(
970+
MSVC_VERSION = "14.2",
970971
options = o
971972
)
972973

contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ def backgroundRun():
19291929
startTime = time.time()
19301930
thread.start()
19311931

1932-
time.sleep( 0.05 )
1932+
time.sleep( 0.01 )
19331933
canceller.cancel()
19341934
thread.join()
19351935

contrib/IECoreUSD/src/IECoreUSD/CurvesAlgo.cpp

+53-16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
IECORE_PUSH_DEFAULT_VISIBILITY
4444
#include "pxr/usd/usdGeom/basisCurves.h"
45+
#include "pxr/usd/usdGeom/nurbsCurves.h"
4546
IECORE_POP_DEFAULT_VISIBILITY
4647

4748
using namespace IECore;
@@ -55,13 +56,37 @@ using namespace IECoreUSD;
5556
namespace
5657
{
5758

58-
IECore::ObjectPtr readCurves( pxr::UsdGeomBasisCurves &curves, pxr::UsdTimeCode time, const Canceller *canceller )
59+
IECore::ObjectPtr readCurves( pxr::UsdGeomCurves &curves, pxr::UsdTimeCode time, const IECore::CubicBasisf &basis, bool periodic, const Canceller *canceller )
5960
{
6061
Canceller::check( canceller );
6162
pxr::VtIntArray vertexCountsArray;
6263
curves.GetCurveVertexCountsAttr().Get( &vertexCountsArray, time );
6364
IECore::IntVectorDataPtr countData = DataAlgo::fromUSD( vertexCountsArray );
6465

66+
Canceller::check( canceller );
67+
IECoreScene::CurvesPrimitivePtr newCurves = new IECoreScene::CurvesPrimitive( countData, basis, periodic );
68+
PrimitiveAlgo::readPrimitiveVariables( curves, time, newCurves.get(), canceller );
69+
70+
Canceller::check( canceller );
71+
PrimitiveAlgo::readPrimitiveVariable(
72+
curves.GetWidthsAttr(), time, newCurves.get(), "width", PrimitiveAlgo::fromUSD( curves.GetWidthsInterpolation() )
73+
);
74+
75+
return newCurves;
76+
}
77+
78+
bool curvesMightBeTimeVarying( pxr::UsdGeomCurves &curves )
79+
{
80+
return
81+
curves.GetCurveVertexCountsAttr().ValueMightBeTimeVarying() ||
82+
curves.GetWidthsAttr().ValueMightBeTimeVarying() ||
83+
PrimitiveAlgo::primitiveVariablesMightBeTimeVarying( curves )
84+
;
85+
}
86+
87+
IECore::ObjectPtr readBasisCurves( pxr::UsdGeomBasisCurves &curves, pxr::UsdTimeCode time, const Canceller *canceller )
88+
{
89+
6590
// Basis
6691
Canceller::check( canceller );
6792
IECore::CubicBasisf basis = CubicBasisf::linear();
@@ -103,32 +128,44 @@ IECore::ObjectPtr readCurves( pxr::UsdGeomBasisCurves &curves, pxr::UsdTimeCode
103128
IECore::msg( IECore::Msg::Warning, "USDScene", boost::format( "Unsupported wrap \"%1%\"" ) % wrap );
104129
}
105130

106-
// Curves and primvars
131+
return readCurves( curves, time, basis, periodic, canceller );
132+
}
107133

108-
IECoreScene::CurvesPrimitivePtr newCurves = new IECoreScene::CurvesPrimitive( countData, basis, periodic );
109-
PrimitiveAlgo::readPrimitiveVariables( curves, time, newCurves.get(), canceller );
134+
bool basisCurvesMightBeTimeVarying( pxr::UsdGeomBasisCurves &curves )
135+
{
136+
return
137+
curvesMightBeTimeVarying( curves ) ||
138+
curves.GetTypeAttr().ValueMightBeTimeVarying() ||
139+
curves.GetBasisAttr().ValueMightBeTimeVarying() ||
140+
curves.GetWrapAttr().ValueMightBeTimeVarying()
141+
;
142+
}
143+
144+
IECore::ObjectPtr readNurbsCurves( pxr::UsdGeomNurbsCurves &curves, pxr::UsdTimeCode time, const Canceller *canceller )
145+
{
146+
IECore::CubicBasisf basis = IECore::CubicBasisf::linear();
110147

111148
Canceller::check( canceller );
112-
PrimitiveAlgo::readPrimitiveVariable(
113-
curves.GetWidthsAttr(), time, newCurves.get(), "width", PrimitiveAlgo::fromUSD( curves.GetWidthsInterpolation() )
114-
);
149+
pxr::VtIntArray order;
150+
curves.GetOrderAttr().Get( &order, time );
151+
if( std::all_of( order.begin(), order.end(), [] ( int o ) { return o == 4; } ) )
152+
{
153+
basis = CubicBasisf::bSpline();
154+
}
115155

116-
return newCurves;
156+
return readCurves( curves, time, basis, false, canceller );
117157
}
118158

119-
bool curvesMightBeTimeVarying( pxr::UsdGeomBasisCurves &curves )
159+
bool nurbsCurvesMightBeTimeVarying( pxr::UsdGeomNurbsCurves &curves )
120160
{
121161
return
122-
curves.GetCurveVertexCountsAttr().ValueMightBeTimeVarying() ||
123-
curves.GetTypeAttr().ValueMightBeTimeVarying() ||
124-
curves.GetBasisAttr().ValueMightBeTimeVarying() ||
125-
curves.GetWrapAttr().ValueMightBeTimeVarying() ||
126-
curves.GetWidthsAttr().ValueMightBeTimeVarying() ||
127-
PrimitiveAlgo::primitiveVariablesMightBeTimeVarying( curves )
162+
curvesMightBeTimeVarying( curves ) ||
163+
curves.GetOrderAttr().ValueMightBeTimeVarying()
128164
;
129165
}
130166

131-
ObjectAlgo::ReaderDescription<pxr::UsdGeomBasisCurves> g_curvesReaderDescription( pxr::TfToken( "BasisCurves" ), readCurves, curvesMightBeTimeVarying );
167+
ObjectAlgo::ReaderDescription<pxr::UsdGeomBasisCurves> g_curvesReaderDescription( pxr::TfToken( "BasisCurves" ), readBasisCurves, basisCurvesMightBeTimeVarying );
168+
ObjectAlgo::ReaderDescription<pxr::UsdGeomNurbsCurves> g_nurbsCurvesReaderDescription( pxr::TfToken( "NurbsCurves" ), readNurbsCurves, nurbsCurvesMightBeTimeVarying );
132169

133170
} // namespace
134171

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

+52
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,58 @@ def testCurveBasisAndWrap( self ) :
16551655
self.assertEqual( curves2, curves )
16561656
del root
16571657

1658+
def testReadNurbsCurves( self ) :
1659+
1660+
# Write USD file
1661+
1662+
fileName = os.path.join( self.temporaryDirectory(), "nurbs.usda" )
1663+
stage = pxr.Usd.Stage.CreateNew( fileName )
1664+
1665+
curves = pxr.UsdGeom.NurbsCurves.Define( stage, "/cubic" )
1666+
curves.CreateCurveVertexCountsAttr().Set( [ 4 ] )
1667+
curves.CreatePointsAttr().Set( [ ( x, x, x ) for x in range( 0, 4 ) ] )
1668+
curves.CreateOrderAttr().Set( [ 4 ] )
1669+
curves.CreateKnotsAttr().Set( [ 0, 0, 0, 0.333, 0.666, 1, 1, 1 ] )
1670+
1671+
curves = pxr.UsdGeom.NurbsCurves.Define( stage, "/nonCubic" )
1672+
curves.CreateCurveVertexCountsAttr().Set( [ 4 ] )
1673+
curves.CreatePointsAttr().Set( [ ( x, x, x ) for x in range( 0, 4 ) ] )
1674+
curves.CreateOrderAttr().Set( [ 3 ] )
1675+
curves.CreateKnotsAttr().Set( [ 0, 0, 0, 0.5, 1, 1, 1 ] )
1676+
1677+
stage.GetRootLayer().Save()
1678+
del stage
1679+
1680+
# Load and check
1681+
1682+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
1683+
1684+
cubic = root.child( "cubic" ).readObject( 0.0 )
1685+
self.assertIsInstance( cubic, IECoreScene.CurvesPrimitive )
1686+
self.assertEqual( cubic.verticesPerCurve(), IECore.IntVectorData( [ 4 ] ) )
1687+
self.assertEqual( cubic.basis(), IECore.CubicBasisf.bSpline() )
1688+
self.assertEqual( cubic.periodic(), False )
1689+
self.assertEqual(
1690+
cubic["P"].data,
1691+
IECore.V3fVectorData(
1692+
[ imath.V3f( x ) for x in range( 0, 4 ) ],
1693+
IECore.GeometricData.Interpretation.Point
1694+
)
1695+
)
1696+
1697+
nonCubic = root.child( "nonCubic" ).readObject( 0.0 )
1698+
self.assertIsInstance( nonCubic, IECoreScene.CurvesPrimitive )
1699+
self.assertEqual( nonCubic.verticesPerCurve(), IECore.IntVectorData( [ 4 ] ) )
1700+
self.assertEqual( nonCubic.basis(), IECore.CubicBasisf.linear() )
1701+
self.assertEqual( nonCubic.periodic(), False )
1702+
self.assertEqual(
1703+
cubic["P"].data,
1704+
IECore.V3fVectorData(
1705+
[ imath.V3f( x ) for x in range( 0, 4 ) ],
1706+
IECore.GeometricData.Interpretation.Point
1707+
)
1708+
)
1709+
16581710
def testIndexedWidths( self ) :
16591711

16601712
# Write USD file from points with indexed widths

include/IECoreGL/ColorTexture.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ class IECOREGL_API ColorTexture : public Texture
5151

5252
IE_CORE_DECLARERUNTIMETYPEDEXTENSION( IECoreGL::ColorTexture, ColorTextureTypeId, Texture );
5353

54-
/// Constructs an empty texture of the specified dimensions.
54+
/// \todo Remove this constructor when client code has transitioned to the one
55+
/// specifying the internal storage format.
5556
ColorTexture( unsigned int width, unsigned int height );
57+
/// Constructs an empty texture of the specified dimensions and internal storage format.
58+
ColorTexture( unsigned int width, unsigned int height, const GLint internalFormat );
5659
/// Constructs a new ColorTexture. All channels must be of the same type, and must
5760
/// be some form of numeric VectorData.
5861
ColorTexture( unsigned int width, unsigned int height, const IECore::Data *r,

include/IECoreGL/Selector.h

+7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ class IECOREGL_API Selector : boost::noncopyable
9999
/// responsibility to keep the hits vector alive for the lifetime
100100
/// of the Selector.
101101
Selector( const Imath::Box2f &region, Mode mode, std::vector<HitRecord> &hits );
102+
/// Same as above, and if `useCameraDepth` is `true`, the depth
103+
/// values in `hits` will be taken from the camera-space Z coordinate
104+
/// instead of the less precise OpenGL depth buffer.
105+
106+
/// \todo Remove when client code has migrated and use the more
107+
/// precise alternative exclusively.
108+
Selector( const Imath::Box2f &region, Mode mode, std::vector<HitRecord> &hits, bool useCameraDepth );
102109
/// Completes the selection operation, filling in the vector
103110
/// of hits that was passed to the constructor.
104111
virtual ~Selector();
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
//////////////////////////////////////////////////////////////////////////
3+
//
4+
// Copyright (c) 2024, Cinesite VFX Ltd. All rights reserved.
5+
//
6+
// Redistribution and use in source and binary forms, with or without
7+
// modification, are permitted provided that the following conditions are
8+
// met:
9+
//
10+
// * Redistributions of source code must retain the above
11+
// copyright notice, this list of conditions and the following
12+
// disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above
15+
// copyright notice, this list of conditions and the following
16+
// disclaimer in the documentation and/or other materials provided with
17+
// the distribution.
18+
//
19+
// * Neither the name of John Haddon nor the names of
20+
// any other contributors to this software may be used to endorse or
21+
// promote products derived from this software without specific prior
22+
// written permission.
23+
//
24+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25+
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32+
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33+
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34+
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35+
//
36+
//////////////////////////////////////////////////////////////////////////
37+
38+
#ifndef IECOREPYTHON_PYBINDCONVERTER_H
39+
#define IECOREPYTHON_PYBINDCONVERTER_H
40+
41+
#include "boost/python.hpp"
42+
43+
#include "pybind11/pybind11.h"
44+
45+
namespace IECorePython
46+
{
47+
48+
// Registers `boost::python` converters for types
49+
// wrapped using PyBind11.
50+
template<typename T>
51+
struct PyBindConverter
52+
{
53+
54+
static void registerConverters()
55+
{
56+
boost::python::to_python_converter<T, ToPyBind>();
57+
boost::python::converter::registry::push_back(
58+
&FromPyBind::convertible,
59+
&FromPyBind::construct,
60+
boost::python::type_id<T>()
61+
);
62+
}
63+
64+
private :
65+
66+
struct ToPyBind
67+
{
68+
static PyObject *convert( const T &t )
69+
{
70+
pybind11::object o = pybind11::cast( t );
71+
Py_INCREF( o.ptr() );
72+
return o.ptr();
73+
}
74+
};
75+
76+
struct FromPyBind
77+
{
78+
79+
static void *convertible( PyObject *object )
80+
{
81+
pybind11::handle handle( object );
82+
return handle.cast<T>() ? object : nullptr;
83+
}
84+
85+
static void construct( PyObject *object, boost::python::converter::rvalue_from_python_stage1_data *data )
86+
{
87+
void *storage = ( ( boost::python::converter::rvalue_from_python_storage<T> * ) data )->storage.bytes;
88+
T *t = new( storage ) T;
89+
data->convertible = storage;
90+
91+
pybind11::handle handle( object );
92+
*t = handle.cast<T>();
93+
}
94+
95+
};
96+
97+
};
98+
99+
} // namespace IECorePython
100+
101+
#endif // IECOREPYTHON_PYBINDCONVERTER_H
102+

src/IECore/OStreamMessageHandler.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,24 @@ OStreamMessageHandler::~OStreamMessageHandler()
6767

6868
void OStreamMessageHandler::handle( Level level, const std::string &context, const std::string &message )
6969
{
70-
*m_stream << levelAsString( level ) << " : " << context << " : " << message << endl;
70+
const string levelString = levelAsString( level );
71+
// Output the message a line at a time.
72+
for( size_t lineBegin = 0; lineBegin < message.size(); )
73+
{
74+
// Find span to the next newline.
75+
const size_t f = message.find( '\n', lineBegin );
76+
const size_t lineEnd = f == string::npos ? message.size() : f;
77+
// Prefix every line with the level
78+
*m_stream << levelString << " : ";
79+
// Only prefix the first line with the context
80+
if( lineBegin == 0 )
81+
{
82+
*m_stream << context << " : ";
83+
}
84+
// Output line and set up for next one.
85+
*m_stream << std::string_view( message.data() + lineBegin, lineEnd - lineBegin ) << endl;
86+
lineBegin = lineEnd + 1;
87+
}
7188
}
7289

7390
///////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)