MCPcopy Create free account
hub / github.com/axmolengine/axmol / GetDrawableArea

Method GetDrawableArea

tests/live2d-tests/Source/LAppModel.cpp:702–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700}
701
702csmRectF LAppModel::GetDrawableArea(csmInt32 drawableIndex, const CubismMatrix44& vpMatrix, const CubismVector2& windowSize) const
703{
704 CubismMatrix44 currentMatrix(vpMatrix); //Matrixをコピーしないと変質が次回に影響する
705 currentMatrix.MultiplyByMatrix(_modelMatrix);
706
707 const csmInt32 count = _model->GetDrawableVertexCount(drawableIndex);
708 const csmFloat32* vertices = _model->GetDrawableVertices(drawableIndex);
709
710 csmFloat32 left = vertices[0];
711 csmFloat32 right = vertices[0];
712 csmFloat32 top = vertices[1];
713 csmFloat32 bottom = vertices[1];
714
715 for (csmInt32 j = 1; j < count; ++j)
716 {
717 CubismVector2 pos;
718
719 pos.X = vertices[Constant::VertexOffset + j * Constant::VertexStep];
720 pos.Y = vertices[Constant::VertexOffset + j * Constant::VertexStep + 1];
721
722 if (pos.X < left)
723 {
724 left = pos.X; // Min x
725 }
726
727 if (pos.X > right)
728 {
729 right = pos.X; // Max x
730 }
731
732 if (pos.Y < top)
733 {
734 top = pos.Y; // Min y
735 }
736
737 if (pos.Y > bottom)
738 {
739 bottom = pos.Y; // Max y
740 }
741 }
742
743 csmFloat32 convertLeft = left * currentMatrix.GetArray()[0] + top * currentMatrix.GetArray()[1];
744 convertLeft = convertLeft * windowSize.X / 2 + windowSize.X / 2;
745 csmFloat32 convertTop = left * currentMatrix.GetArray()[4] + top * currentMatrix.GetArray()[5];
746 convertTop = convertTop * windowSize.Y / 2 + windowSize.Y / 2;
747 csmFloat32 convertRight = right * currentMatrix.GetArray()[0] + bottom * currentMatrix.GetArray()[1];
748 convertRight = convertRight * windowSize.X / 2 + windowSize.X / 2;
749 csmFloat32 convertBottom = right * currentMatrix.GetArray()[4] + bottom * currentMatrix.GetArray()[5];
750 convertBottom = convertBottom * windowSize.Y / 2 + windowSize.Y / 2;
751
752 return csmRectF(convertLeft, convertTop, (convertRight - convertLeft), (convertBottom - convertTop));
753}
754
755void LAppModel::MakeRenderingTarget()
756{

Callers

nothing calls this directly

Calls 5

csmRectFClass · 0.85
MultiplyByMatrixMethod · 0.80
GetDrawableVerticesMethod · 0.80
GetArrayMethod · 0.80

Tested by

no test coverage detected