Skip to content

Commit 254b61b

Browse files
committed
CoordinateSystem : Remove transform
This is unused now we've removed Renderer. In Gaffer's representation, the transform is held outside the CoordinateSystem anyway, and having an internal one was confusing and prone to error.
1 parent ac1348a commit 254b61b

File tree

5 files changed

+6
-144
lines changed

5 files changed

+6
-144
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Breaking Changes
1313
----------------
1414

1515
- Renderable : Removed `render()` method.
16+
- CoordinateSystem : Removed transform.
1617
- Renderer, AttributeBlock, EditBlock, MotionBlock, TransformBlock, WorldBlock : Removed.
1718
- IECoreHoudini : Removed.
1819
- IECoreMaya : Removed.

include/IECoreScene/CoordinateSystem.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,23 @@
4141
namespace IECoreScene
4242
{
4343

44-
IE_CORE_FORWARDDECLARE( Transform )
45-
46-
/// This calls allows the specification of coordinate systems to
47-
/// Renderers.
44+
/// Allows the specification of coordinate systems to Renderers.
4845
/// \ingroup renderingGroup
4946
class IECORESCENE_API CoordinateSystem : public StateRenderable
5047
{
5148
public:
5249

53-
CoordinateSystem();
54-
CoordinateSystem( const std::string &name, TransformPtr transform=nullptr );
50+
CoordinateSystem( const std::string &name = "unspecified" );
5551
~CoordinateSystem() override;
5652

5753
IE_CORE_DECLAREEXTENSIONOBJECT( CoordinateSystem, CoordinateSystemTypeId, StateRenderable );
5854

5955
const std::string &getName() const;
6056
void setName( const std::string &name );
6157

62-
/// Returns the Transform applied to the coordinate system.
63-
/// This is the local transform relative to the parent of
64-
/// the coordinate system (usually a Group). May return 0
65-
/// if no transform has been applied.
66-
Transform *getTransform();
67-
const Transform *getTransform() const;
68-
/// Sets the Transform applied to the coordinate system.
69-
void setTransform( TransformPtr transform );
70-
7158
private:
7259

7360
std::string m_name;
74-
TransformPtr m_transform;
7561

7662
static const unsigned int m_ioVersion;
7763
};

src/IECoreScene/CoordinateSystem.cpp

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
#include "IECoreScene/CoordinateSystem.h"
3636

37-
#include "IECoreScene/Transform.h"
38-
3937
#include "IECore/MurmurHash.h"
4038

4139
using namespace IECore;
@@ -47,13 +45,8 @@ static IndexedIO::EntryID g_transformEntry("transform");
4745
const unsigned int CoordinateSystem::m_ioVersion = 0;
4846
IE_CORE_DEFINEOBJECTTYPEDESCRIPTION( CoordinateSystem );
4947

50-
CoordinateSystem::CoordinateSystem()
51-
: m_name( "unspecified" ), m_transform( nullptr )
52-
{
53-
}
54-
55-
CoordinateSystem::CoordinateSystem( const std::string &name, TransformPtr transform )
56-
: m_name( name ), m_transform( transform )
48+
CoordinateSystem::CoordinateSystem( const std::string &name )
49+
: m_name( name )
5750
{
5851
}
5952

@@ -71,21 +64,6 @@ void CoordinateSystem::setName( const std::string &name )
7164
m_name = name;
7265
}
7366

74-
Transform *CoordinateSystem::getTransform()
75-
{
76-
return m_transform.get();
77-
}
78-
79-
const Transform *CoordinateSystem::getTransform() const
80-
{
81-
return m_transform.get();
82-
}
83-
84-
void CoordinateSystem::setTransform( TransformPtr transform )
85-
{
86-
m_transform = transform;
87-
}
88-
8967
bool CoordinateSystem::isEqualTo( const Object *other ) const
9068
{
9169
if( !StateRenderable::isEqualTo( other ) )
@@ -97,51 +75,27 @@ bool CoordinateSystem::isEqualTo( const Object *other ) const
9775
{
9876
return false;
9977
}
100-
if( (bool)m_transform != (bool)c->m_transform )
101-
{
102-
return false;
103-
}
104-
if( m_transform )
105-
{
106-
return m_transform->isEqualTo( c->m_transform.get() );
107-
}
10878
return true;
10979
}
11080

11181
void CoordinateSystem::memoryUsage( Object::MemoryAccumulator &a ) const
11282
{
11383
StateRenderable::memoryUsage( a );
11484
a.accumulate( m_name.capacity() + sizeof( m_name ) );
115-
if( m_transform )
116-
{
117-
a.accumulate( m_transform.get() );
118-
}
11985
}
12086

12187
void CoordinateSystem::copyFrom( const Object *other, CopyContext *context )
12288
{
12389
StateRenderable::copyFrom( other, context );
12490
const CoordinateSystem *c = static_cast<const CoordinateSystem *>( other );
12591
m_name = c->m_name;
126-
if( c->m_transform )
127-
{
128-
m_transform = context->copy<Transform>( c->m_transform.get() );
129-
}
130-
else
131-
{
132-
m_transform = nullptr;
133-
}
13492
}
13593

13694
void CoordinateSystem::save( SaveContext *context ) const
13795
{
13896
StateRenderable::save( context );
13997
IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion );
14098
container->write( g_nameEntry, m_name );
141-
if( m_transform )
142-
{
143-
context->save( m_transform.get(), container.get(), g_transformEntry );
144-
}
14599
}
146100

147101
void CoordinateSystem::load( LoadContextPtr context )
@@ -150,22 +104,10 @@ void CoordinateSystem::load( LoadContextPtr context )
150104
unsigned int v = m_ioVersion;
151105
ConstIndexedIOPtr container = context->container( staticTypeName(), v );
152106
container->read( g_nameEntry, m_name );
153-
m_transform = nullptr;
154-
try
155-
{
156-
m_transform = context->load<Transform>( container.get(), g_transformEntry );
157-
}
158-
catch( ... )
159-
{
160-
}
161107
}
162108

163109
void CoordinateSystem::hash( MurmurHash &h ) const
164110
{
165111
StateRenderable::hash( h );
166112
h.append( m_name );
167-
if( m_transform )
168-
{
169-
m_transform->hash( h );
170-
}
171113
}

src/IECoreScene/bindings/CoordinateSystemBinding.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "CoordinateSystemBinding.h"
3838

3939
#include "IECoreScene/CoordinateSystem.h"
40-
#include "IECoreScene/Transform.h"
4140

4241
#include "IECorePython/RunTimeTypedBinding.h"
4342

@@ -51,13 +50,9 @@ namespace IECoreSceneModule
5150
void bindCoordinateSystem()
5251
{
5352
RunTimeTypedClass<CoordinateSystem>()
54-
.def( init<>() )
55-
.def( init<const std::string &>() )
56-
.def( init<const std::string &, TransformPtr>() )
53+
.def( init<const std::string &>( ( arg( "name" ) = "unspecified" ) ) )
5754
.def( "getName", &CoordinateSystem::getName, return_value_policy<copy_const_reference>() )
5855
.def( "setName", &CoordinateSystem::setName )
59-
.def( "getTransform", (Transform *(CoordinateSystem::*)())&CoordinateSystem::getTransform, return_value_policy<CastToIntrusivePtr>() )
60-
.def( "setTransform", &CoordinateSystem::setTransform )
6156
;
6257
}
6358

test/IECoreScene/CoordinateSystemTest.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -70,57 +70,10 @@ def testHash( self ) :
7070
b.setName( "a" )
7171
self.assertEqual( a.hash(), b.hash() )
7272

73-
b.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) )
74-
self.assertNotEqual( a.hash(), b.hash() )
75-
76-
def testTransform( self ) :
77-
78-
c = IECoreScene.CoordinateSystem()
79-
self.assertEqual( c.getTransform(), None )
80-
81-
c = IECoreScene.CoordinateSystem( "test" )
82-
self.assertEqual( c.getName(), "test" )
83-
self.assertEqual( c.getTransform(), None )
84-
self.assertEqual( c, c.copy() )
85-
86-
c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( imath.M44f() ) )
87-
self.assertEqual( c.getName(), "test" )
88-
self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) )
89-
self.assertEqual( c, c.copy() )
90-
91-
cc = c.copy()
92-
self.assertEqual( cc.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) )
93-
self.assertFalse( c.getTransform().isSame( cc.getTransform() ) )
94-
95-
c.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) )
96-
self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) )
97-
98-
c.setTransform( None )
99-
self.assertEqual( c.getTransform(), None )
100-
101-
cc = c.copy()
102-
self.assertEqual( cc.getTransform(), None )
103-
10473
def testLoadCobFromBeforeTransforms( self ) :
10574

10675
c = IECore.ObjectReader( os.path.join( "test", "IECore", "data", "cobFiles", "coordinateSystemBeforeTransforms.cob" ) ).read()
107-
10876
self.assertEqual( c.getName(), "test" )
109-
self.assertEqual( c.getTransform(), None )
110-
111-
def testLoadCobWithTransform( self ) :
112-
113-
c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( imath.M44f() ) )
114-
IECore.ObjectWriter( c, os.path.join( "test", "IECore", "data", "coordSys.cob" ) ).write()
115-
c = IECore.ObjectReader( os.path.join( "test", "IECore", "data", "coordSys.cob" ) ).read()
116-
117-
self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) )
118-
119-
c = IECoreScene.CoordinateSystem( "test", None )
120-
IECore.ObjectWriter( c, os.path.join( "test", "IECore", "data", "coordSys.cob" ) ).write()
121-
c = IECore.ObjectReader( os.path.join( "test", "IECore", "data", "coordSys.cob" ) ).read()
122-
123-
self.assertEqual( c.getTransform(), None )
12477

12578
def testEquality( self ) :
12679

@@ -134,21 +87,6 @@ def testEquality( self ) :
13487
self.assertNotEqual( c2, c1 )
13588
c1.setName( "test" )
13689

137-
c1.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) )
138-
self.assertNotEqual( c1, c2 )
139-
self.assertNotEqual( c2, c1 )
140-
141-
c2.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) )
142-
self.assertEqual( c1, c2 )
143-
self.assertEqual( c2, c1 )
144-
145-
def testMemoryUsage( self ) :
146-
147-
c = IECoreScene.CoordinateSystem( "test" )
148-
m = c.memoryUsage()
149-
c.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) )
150-
self.assertTrue( c.memoryUsage() > m )
151-
15290
def tearDown( self ) :
15391

15492
if os.path.exists( os.path.join( "test", "IECore", "data", "coordSys.cob" ) ) :

0 commit comments

Comments
 (0)