Skip to content

Commit

Permalink
Fix force vector arrows not casting shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Aug 14, 2024
1 parent c01b876 commit 2029049
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
currently only works for `ExternalForce`s in the model (#904) and `GeometryPath`s (#907).
- The `Show Forces' Linear/Rotation Component` option was reworded to `Forces on Bodies` and
`Torques on Bodies` to reflect what's actually being shown
- Fixed force vector arrows not casting shadows
- Internal: `RenderTextureDescriptor` was refactored into a POD struct called `RenderTextureParams`
for ease-of-use

Expand Down
28 changes: 12 additions & 16 deletions src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace
m_Out{out}
{}

SceneCache& updMeshCache()
SceneCache& updSceneCache()
{
return m_MeshCache;
}
Expand Down Expand Up @@ -274,7 +274,7 @@ namespace
for (const SimTK::DecorativeGeometry& geom : m_GeomList)
{
GenerateDecorations(
updMeshCache(),
updSceneCache(),
getMatterSubsystem(),
getState(),
geom,
Expand All @@ -293,7 +293,7 @@ namespace
for (const SimTK::DecorativeGeometry& geom : m_GeomList)
{
GenerateDecorations(
updMeshCache(),
updSceneCache(),
getMatterSubsystem(),
getState(),
geom,
Expand Down Expand Up @@ -382,7 +382,7 @@ namespace
.head_thickness = (fixupScaleFactor*0.01f),
.color = c_BodyForceArrowColor,
};
draw_arrow(rs.updMeshCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
draw_arrow(rs.updSceneCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
{
rs.consume(force, std::move(decoration));
});
Expand All @@ -403,7 +403,7 @@ namespace
.head_thickness = (fixupScaleFactor*0.01f),
.color = c_BodyTorqueArrowColor,
};
draw_arrow(rs.updMeshCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
draw_arrow(rs.updSceneCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
{
rs.consume(force, std::move(decoration));
});
Expand Down Expand Up @@ -459,7 +459,7 @@ namespace
.head_thickness = 0.01f * rs.getFixupScaleFactor(),
.color = c_PointForceArrowColor,
};
draw_arrow(rs.updMeshCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
draw_arrow(rs.updSceneCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
{
rs.consume(force, std::move(decoration));
});
Expand All @@ -477,7 +477,7 @@ namespace
.head_thickness = 0.01f * rs.getFixupScaleFactor(),
.color = c_PointForceArrowColor,
};
draw_arrow(rs.updMeshCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
draw_arrow(rs.updSceneCache(), arrowProperties, [&force, &rs](SceneDecoration&& decoration)
{
rs.consume(force, std::move(decoration));
});
Expand Down Expand Up @@ -532,8 +532,7 @@ namespace
.head_thickness = 0.01f * rs.getFixupScaleFactor(),
.color = c_PointForceArrowColor,
};

draw_arrow(rs.updMeshCache(), arrowProperties, [&pathActuator, &rs](SceneDecoration&& decoration)
draw_arrow(rs.updSceneCache(), arrowProperties, [&pathActuator, &rs](SceneDecoration&& decoration)
{
rs.consume(*pathActuator, std::move(decoration));
});
Expand All @@ -555,7 +554,7 @@ namespace
const float radius = c_GeometryPathBaseRadius * rs.getFixupScaleFactor();

rs.consume(p2p, SceneDecoration{
.mesh = rs.updMeshCache().cylinder_mesh(),
.mesh = rs.updSceneCache().cylinder_mesh(),
.transform = cylinder_to_line_segment_transform({p1, p2}, radius),
.color = {0.7f, 0.7f, 0.7f, 1.0f},
.flags = SceneDecorationFlags::CastsShadows,
Expand Down Expand Up @@ -963,8 +962,7 @@ namespace
.head_thickness = (fixupScaleFactor*0.01f),
.color = color,
};

draw_arrow(rs.updMeshCache(), arrowProperties, [&muscle, &rs](SceneDecoration&& d)
draw_arrow(rs.updSceneCache(), arrowProperties, [&muscle, &rs](SceneDecoration&& d)
{
rs.consume(muscle, std::move(d));
});
Expand Down Expand Up @@ -1115,8 +1113,7 @@ namespace
.head_thickness = fixupScaleFactor*baseRadius,
.color = c_PointForceArrowColor,
};

draw_arrow(rs.updMeshCache(), arrowProperties, [&hcf, &rs](SceneDecoration&& d)
draw_arrow(rs.updSceneCache(), arrowProperties, [&hcf, &rs](SceneDecoration&& d)
{
rs.consume(hcf, std::move(d));
});
Expand Down Expand Up @@ -1155,8 +1152,7 @@ void osc::GenerateSubcomponentDecorations(
{
OSC_PERF("OpenSimRenderer/GenerateModelDecorations");

RendererState rendererState
{
RendererState rendererState{
meshCache,
model,
state,
Expand Down
2 changes: 2 additions & 0 deletions src/oscar/Graphics/Scene/SceneHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void osc::draw_arrow(
.mesh = cache.cone_mesh(),
.transform = cylinder_to_line_segment_transform({tip_start, props.end}, props.head_thickness),
.color = props.color,
.flags = props.decoration_flags,
});

// if there's space for it, emit the neck cylinder
Expand All @@ -189,6 +190,7 @@ void osc::draw_arrow(
.mesh = cache.cylinder_mesh(),
.transform = cylinder_to_line_segment_transform({props.start, tip_start}, props.neck_thickness),
.color = props.color,
.flags = props.decoration_flags,
});
}
}
Expand Down
1 change: 1 addition & 0 deletions src/oscar/Graphics/Scene/SceneHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace osc
float neck_thickness{};
float head_thickness{};
Color color = Color::black();
SceneDecorationFlags decoration_flags = SceneDecorationFlags::CastsShadows;
};
void draw_arrow(
SceneCache&,
Expand Down

0 comments on commit 2029049

Please sign in to comment.