Skip to content

Commit

Permalink
fixed material transparency enable/disable
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor-Haefner committed Apr 17, 2016
1 parent f126a94 commit ad8e549
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/core/objects/material/VRMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ void VRMaterial::setTransparency(float c) {
//enableTransparency();
}

void VRMaterial::enableTransparency() {
void VRMaterial::enableTransparency(bool user_override) {
force_transparency = user_override;
auto md = mats[activePass];
if (md->blendChunk == 0) {
md->blendChunk = BlendChunk::create();
Expand All @@ -688,7 +689,9 @@ void VRMaterial::enableTransparency() {
}
}

void VRMaterial::clearTransparency() {
void VRMaterial::clearTransparency(bool user_override) {
if (user_override) force_transparency = false;
if (force_transparency && !user_override) return;
auto md = mats[activePass];
md->clearChunk(md->blendChunk);
md->clearChunk(md->depthChunk);
Expand Down
5 changes: 3 additions & 2 deletions src/core/objects/material/VRMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class VRMaterial : public VRObject {
MultiPassMaterialMTRecPtr passes;
vector<VRMatData*> mats;
int activePass = 0;
bool force_transparency = false;
bool deferred = false;

VRObjectPtr copy(vector<VRObjectPtr> children);
Expand Down Expand Up @@ -95,8 +96,8 @@ class VRMaterial : public VRObject {
void setEmission(Color3f c);
void setTransparency(float t);
void setDepthTest(int d);
void enableTransparency();
void clearTransparency();
void enableTransparency(bool user_override = false);
void clearTransparency(bool user_override = false);
void setLineWidth(int w, bool smooth = true);
void setPointSize(int s, bool smooth = true);
void setWireFrame(bool b);
Expand Down
4 changes: 2 additions & 2 deletions src/core/scripting/VRPyMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ PyMethodDef VRPyMaterial::methods[] = {

PyObject* VRPyMaterial::enableTransparency(VRPyMaterial* self) {
if (self->objPtr == 0) { PyErr_SetString(err, "VRPyMaterial::enableTransparency, C obj is invalid"); return NULL; }
self->objPtr->enableTransparency();
self->objPtr->enableTransparency(true);
Py_RETURN_TRUE;
}

PyObject* VRPyMaterial::clearTransparency(VRPyMaterial* self) {
if (self->objPtr == 0) { PyErr_SetString(err, "VRPyMaterial::clearTransparency, C obj is invalid"); return NULL; }
self->objPtr->clearTransparency();
self->objPtr->clearTransparency(true);
Py_RETURN_TRUE;
}

Expand Down

0 comments on commit ad8e549

Please sign in to comment.