Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to unset segmentation object ID #814

Merged
merged 2 commits into from
Feb 14, 2018
Merged
Changes from 1 commit
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
Next Next commit
Allow negative stencil values to turn off custom depth rendering
This is useful when you don't want to have certain objects show up in the
segmentation view, such as leaves on the floor.
  • Loading branch information
aburgm committed Feb 14, 2018
commit 605f42e8bd84c20be8feb4945225b5eb53b7de3a
33 changes: 27 additions & 6 deletions Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,45 @@ void UAirBlueprintLib::InitializeObjectStencilID(T* mesh, bool ignore_existing)
template<typename T>
void UAirBlueprintLib::SetObjectStencilID(T* mesh, int object_id)
{
mesh->SetCustomDepthStencilValue(object_id);
mesh->SetRenderCustomDepth(true);
if (object_id < 0)
{
mesh->SetRenderCustomDepth(false);
}
else
{
mesh->SetCustomDepthStencilValue(object_id);
mesh->SetRenderCustomDepth(true);
}
//mesh->SetVisibility(false);
//mesh->SetVisibility(true);
}

void UAirBlueprintLib::SetObjectStencilID(ALandscapeProxy* mesh, int object_id)
{
mesh->CustomDepthStencilValue = object_id;
mesh->bRenderCustomDepth = true;
if (object_id < 0)
{
mesh->bRenderCustomDepth = false;
}
else
{
mesh->CustomDepthStencilValue = object_id;
mesh->bRenderCustomDepth = true;
}

// Explicitly set the custom depth state on the components so the
// render state is marked dirty and the update actually takes effect
// immediately.
for (ULandscapeComponent* comp : mesh->LandscapeComponents)
{
comp->SetCustomDepthStencilValue(object_id);
comp->SetRenderCustomDepth(true);
if (object_id < 0)
{
comp->SetRenderCustomDepth(false);
}
else
{
comp->SetCustomDepthStencilValue(object_id);
comp->SetRenderCustomDepth(true);
}
}
}

Expand Down