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

Commit 38ea95f

Browse files
MortimerGorophilip-lamb
authored andcommitted
Fix pointerColor changes on Wave devices (#1367)
1 parent 462d0de commit 38ea95f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/src/main/cpp/ControllerContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct ControllerContainer::State {
5555
}
5656

5757
void updatePointerColor(Controller& aController) {
58-
if (aController.beamParent) {
58+
if (aController.beamParent && aController.beamParent->GetNodeCount() > 0) {
5959
GeometryPtr geometry = std::dynamic_pointer_cast<vrb::Geometry>(aController.beamParent->GetNode(0));
6060
if (geometry) {
6161
geometry->GetRenderState()->SetMaterial(pointerColor, pointerColor, vrb::Color(0.0f, 0.0f, 0.0f), 0.0f);

app/src/main/cpp/Pointer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct Pointer::State {
4545
vrb::TransformPtr pointerScale;
4646
vrb::GeometryPtr geometry;
4747
WidgetPtr hitWidget;
48+
vrb::Color pointerColor;
4849

4950
State() = default;
5051
~State() {
@@ -62,6 +63,7 @@ struct Pointer::State {
6263
transform->AddNode(pointerScale);
6364
root->AddNode(transform);
6465
root->ToggleAll(false);
66+
pointerColor = POINTER_COLOR_INNER;
6567
}
6668

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

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

164167
void
165168
Pointer::SetPointerColor(const vrb::Color& aColor) {
169+
m.pointerColor = aColor;
166170
if (m.layer) {
167171
m.layer->SetTintColor(aColor);
168172
} if (m.geometry) {

0 commit comments

Comments
 (0)