Skip to content

Commit

Permalink
NWN: Main menu button display fix
Browse files Browse the repository at this point in the history
Buttons on the main menu for NWN might have alpha values that
need to be respected.
Additional:
- Portrait border colours correctly set.
- Fetch correct rendering mesh when building active light list.

Signed-off-by: mirv <mirv.sillyfish@gmail.com>
  • Loading branch information
mirv-sillyfish committed Oct 19, 2023
1 parent 983398e commit a1d06f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/engines/nwn/gui/widgets/portrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ void Portrait::setBorderColor(float bR, float bG, float bB, float bA) {
GfxMan.lockFrame();
_bColour[0] = bR;
_bColour[1] = bG;
_bColour[1] = bB;
_bColour[1] = bA;
_bColour[2] = bB;
_bColour[3] = bA;
GfxMan.unlockFrame();
}

Expand Down
6 changes: 4 additions & 2 deletions src/graphics/aurora/model_nwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ void ModelNode_NWN_Binary::readMesh(Model_NWN::ParserContext &ctx) {
_mesh->beaming = ctx.mdl->readUint32LE() == 1;
_mesh->render = ctx.mdl->readUint32LE() == 1;

_mesh->transparencyHint = ctx.mdl->readUint32LE() == 1;
_mesh->transparencyHint = ctx.mdl->readUint32LE();

ctx.mdl->skip(4); // Unknown

Expand Down Expand Up @@ -1132,10 +1132,12 @@ void ModelNode_NWN_Binary::readNodeControllers(Model_NWN::ParserContext &ctx,
throw Common::Exception("Alpha controller with %d values", columnCount);

// Starting alpha
if (data[timeIndex + 0] == 0.0f)
if (data[timeIndex + 0] == 0.0f) {
_alpha = data[dataIndex + 0];
if (data[dataIndex + 0] == 0.0f)
// TODO: Just disabled rendering if alpha == 0.0 for now
_render = false;
}
} else if (type == kControllerTypeRadius) {
if (columnCount != 1)
throw Common::Exception("Radius controller with %d values", columnCount);
Expand Down
14 changes: 7 additions & 7 deletions src/graphics/aurora/modelnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,11 @@ void ModelNode::calcRenderTransform(const glm::mat4 &parentTransform) {
void ModelNode::renderImmediate(const glm::mat4 &parentTransform) {
calcRenderTransform(parentTransform);
/**
* Ignoring _render for now because it's being falsely set to false.
* Ignoring _render for now because it's being falsely set to false. Later it would be nice
* to make some function that checks for all the "don't render" scenarios and only update
* them when there's a change - not run the checks every single frame.
* One example is if there's some kind of animation that changes the alpha value of a node,
* then the "render or not" check is only needed when the animation updates - not every frame.
*/
/* if (_render) {} */

Expand All @@ -849,10 +853,8 @@ void ModelNode::renderImmediate(const glm::mat4 &parentTransform) {
*/
buildMaterial();
} else {
if (_mesh) {
LightMan.buildActiveLights(glm::vec3(_renderTransform[3]), _mesh->radius);
}
for (size_t i = 0; i < _renderableArray.size(); ++i) {
LightMan.buildActiveLights(glm::vec3(_renderTransform[3]), getMesh()->radius);
_renderableArray[i].renderImmediate(_renderTransform);
}
}
Expand All @@ -873,10 +875,8 @@ void ModelNode::renderImmediate() const {
* will take care of any _dirtyRender check. There is therefore no need to be perform
* that check again here.
*/
if (_mesh) {
LightMan.buildActiveLights(glm::vec3(_renderTransform[3]), _mesh->radius);
}
for (size_t i = 0; i < _renderableArray.size(); ++i) {
LightMan.buildActiveLights(glm::vec3(_renderTransform[3]), getMesh()->radius);
_renderableArray[i].renderImmediate();
}
}
Expand Down

0 comments on commit a1d06f7

Please sign in to comment.