Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix pointerColor changes on Wave devices #1367

Merged
merged 1 commit into from
Jul 4, 2019
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
2 changes: 1 addition & 1 deletion app/src/main/cpp/ControllerContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ControllerContainer::State {
}

void updatePointerColor(Controller& aController) {
if (aController.beamParent) {
if (aController.beamParent && aController.beamParent->GetNodeCount() > 0) {
GeometryPtr geometry = std::dynamic_pointer_cast<vrb::Geometry>(aController.beamParent->GetNode(0));
if (geometry) {
geometry->GetRenderState()->SetMaterial(pointerColor, pointerColor, vrb::Color(0.0f, 0.0f, 0.0f), 0.0f);
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/cpp/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct Pointer::State {
vrb::TransformPtr pointerScale;
vrb::GeometryPtr geometry;
WidgetPtr hitWidget;
vrb::Color pointerColor;

State() = default;
~State() {
Expand All @@ -62,6 +63,7 @@ struct Pointer::State {
transform->AddNode(pointerScale);
root->AddNode(transform);
root->ToggleAll(false);
pointerColor = POINTER_COLOR_INNER;
}

vrb::GeometryPtr createCircle(const int resolution, const float radius, const float offset) {
Expand Down Expand Up @@ -109,7 +111,7 @@ struct Pointer::State {
vrb::GeometryPtr geometryOuter = createCircle(kResolution, kOuterRadius, kOffset);

vrb::RenderStatePtr state = vrb::RenderState::Create(create);
state->SetMaterial(POINTER_COLOR_INNER, POINTER_COLOR_INNER, vrb::Color(0.0f, 0.0f, 0.0f), 0.0f);
state->SetMaterial(pointerColor, pointerColor, vrb::Color(0.0f, 0.0f, 0.0f), 0.0f);
geometry->SetRenderState(state);
vrb::RenderStatePtr stateOuter = vrb::RenderState::Create(create);
stateOuter->SetMaterial(POINTER_COLOR_OUTER, POINTER_COLOR_OUTER, vrb::Color(0.0f, 0.0f, 0.0f), 0.0f);
Expand All @@ -130,6 +132,7 @@ Pointer::Load(const DeviceDelegatePtr& aDevice) {
VRLayerQuadPtr layer = aDevice->CreateLayerQuad(36, 36, VRLayerQuad::SurfaceType::AndroidSurface);
if (layer) {
m.layer = layer;
m.layer->SetTintColor(m.pointerColor);
const float size = kOuterRadius * 2.0f;
layer->SetWorldSize(size, size);
layer->SetSurfaceChangedDelegate([](const VRLayer& aLayer, VRLayer::SurfaceChange aChange, const std::function<void()>& aCallback) {
Expand Down Expand Up @@ -163,6 +166,7 @@ Pointer::SetScale(const vrb::Vector& aHitPoint, const vrb::Matrix& aHeadTransfor

void
Pointer::SetPointerColor(const vrb::Color& aColor) {
m.pointerColor = aColor;
if (m.layer) {
m.layer->SetTintColor(aColor);
} if (m.geometry) {
Expand Down