Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Fixes
- Fixed reading of primitives containing `primvars:normals`. These are now correctly loaded as a primitive variable called `N`, taking precedence over the UsdGeomPointBased `normals` attribute.
- Fixed writing of indexed normals so that the indexing is retained on load. Note that this means that normals are now _always_ written as `primvars:normals` and never via the UsdGeomPointBased `normals` attribute.

API
---

- IECoreGL::PointsPrimitive : Added `renderUsesGLPoints()` method.
- IECoreGL::CurvesPrimitive : Added `renderUsesGLLines()` method.

10.4.6.0 (relative to 10.4.5.0)
========

Expand Down
3 changes: 3 additions & 0 deletions include/IECoreGL/CurvesPrimitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class IECOREGL_API CurvesPrimitive : public Primitive
void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override;
const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override;
void render( const State *currentState, IECore::TypeId style ) const override;
/// Returns `true` if `render( state )` will render the curves as `GL_LINES`,
/// and `false` if the curves will be rendered as ribbons.
bool renderUsesGLLines( const State *state ) const;
/// Just renders each segment as linear with GL_LINES.
void renderInstances( size_t numInstances = 1 ) const override;

Expand Down
4 changes: 4 additions & 0 deletions include/IECoreGL/PointsPrimitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class IECOREGL_API PointsPrimitive : public Primitive
void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override;
const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override;
void render( const State *currentState, IECore::TypeId style ) const override;
/// Returns `true` if `render( state )` will render the points as `GL_POINTS`,
/// and `false` if the curves will be rendered as geometry such as disks or
/// spheres.
bool renderUsesGLPoints( const State *state ) const;
void renderInstances( size_t numInstances = 1 ) const override;

//! @name StateComponents
Expand Down
12 changes: 12 additions & 0 deletions src/IECoreGL/CurvesPrimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ void CurvesPrimitive::renderMode( const State *state, bool &linear, bool &ribbon
ribbons = !state->get<UseGLLines>()->value();
}

bool CurvesPrimitive::renderUsesGLLines( const State *state ) const
{
if( const auto s = state->get<UseGLLines>() )
{
if( s->value() )
{
return true;
}
}
return glslVersion() < 150;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks like it will work fine, but it does feel a little weird that it is so close to renderMode. Why not just call renderMode and check the "linear" return ... I guess it could be perf critical so you want to skip the basis compare? Why this check if state->get<UseGLLines>() is valid before dereferencing it, but renderMode doesn't?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could be perf critical so you want to skip the basis compare?

Yep, that.

Why this check if state->get() is valid before dereferencing it, but renderMode doesn't?

The docs for Primitive::render() say that state must be complete, so that the get() will never return null. In practice in Gaffer the state will also be complete here, but since I didn't document that as a requirement I threw in the check.

}

const std::string &CurvesPrimitive::cubicLinesGeometrySource()
{
static std::string s =
Expand Down
5 changes: 5 additions & 0 deletions src/IECoreGL/PointsPrimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ void PointsPrimitive::render( const State *currentState, IECore::TypeId style )
}
}

bool PointsPrimitive::renderUsesGLPoints( const State *state ) const
{
return effectiveType( state ) == Point;
}

void PointsPrimitive::renderInstances( size_t numInstances ) const
{
glDrawArraysInstancedARB( GL_POINTS, 0, m_memberData->points->readable().size(), numInstances );
Expand Down