Skip to content

Commit

Permalink
Fixed some opacity-related issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuAuahDark committed Jan 12, 2019
1 parent e018faa commit 3e0cdf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Live2LOVE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ extern "C" {
// Live2LOVE
#include "Live2LOVE.h"

// Live2D Library (additional)
// Live2D
#include "base/IBaseContext.h"
#include "model/PartsData.h"

// RefData
#include "RefData.h"
Expand Down Expand Up @@ -223,6 +224,7 @@ void live2love::Live2LOVE::setupMeshData()
mesh->modelContext = modelContext;
mesh->drawDataIndex = i;
mesh->partsIndex = dctx->getPartsIndex();
mesh->partsContext = modelContext->getPartsContext(mesh->partsIndex);

// Create mesh table list
int numPoints;
Expand Down Expand Up @@ -254,8 +256,7 @@ void live2love::Live2LOVE::setupMeshData()
m.y = points[k * 2 + 1];
m.u = uvmap[k * 2 + 0];
m.v = uvmap[k * 2 + 1];
m.r = m.g = m.b = 255;
m.a = floor(opacity * 255.0);
m.r = m.g = m.b = m.a = 255; // set later
}
mesh->tableRefID = RefData::setRef(L, -1); // Add FileData reference
mesh->tablePointer = meshDataRaw;
Expand Down Expand Up @@ -334,8 +335,9 @@ void live2love::Live2LOVE::update(double dT)
RefData::getRef(L, mesh->tableRefID);
int polygonCount, meshLen;
double opacity =
double(mesh->drawContext->interpolatedOpacity) *
double(mesh->drawContext->baseOpacity);
((double) mesh->drawData->getOpacity(*mesh->modelContext, mesh->drawContext)) *
((double) mesh->partsContext->getPartsOpacity()) *
((double) mesh->drawContext->baseOpacity);
l2d_index *vertexMap = mesh->drawData->getIndexArray(&polygonCount);
l2d_pointf *points = model->getTransformedPoints(mesh->drawDataIndex, &meshLen);
meshLen = polygonCount * 3;
Expand Down
2 changes: 2 additions & 0 deletions src/Live2LOVE.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace live2love
live2d::ModelContext *modelContext;
// IDrawData context
live2d::IDrawContext *drawContext;
// PartsDataContext
live2d::PartsDataContext *partsContext;
// Mesh object reference and mesh table reference
int meshRefID, tableRefID;
Live2LOVEMeshFormat *tablePointer;
Expand Down

0 comments on commit 3e0cdf0

Please sign in to comment.