Skip to content

Commit

Permalink
Fix ptAttribLayer being exported incorrectly from Max.
Browse files Browse the repository at this point in the history
Using the pick material button class causes the underlying mipmap to be
exposed to Python instead of the layer. Therefore we add a shim to only
expose the layer.
  • Loading branch information
Hoikas committed Nov 16, 2024
1 parent 5cdc425 commit 5d31cb8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/MaxPlugin/MaxComponent/plAutoUIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void plAutoUIBase::AddPickLayerButton(int16_t id, const ST::string& scriptName,
fDesc->AddParam(id, ST2M(scriptNameNew), TYPE_REFTARG, 0, 0,
p_end,
p_end);
plAutoUIParam* param = new plPickMaterialButtonParam(id, name);
plAutoUIParam* param = new plPickLayerButtonParam(id, name);
param->SetVisInfo(vid, std::move(vstates));
fParams.push_back(param);
}
Expand Down
24 changes: 24 additions & 0 deletions Sources/MaxPlugin/MaxComponent/plAutoUIParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,30 @@ bool plPickMaterialAnimationButtonParam::IsMyMessage(UINT msg, WPARAM wParam, LP
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

plKey plPickLayerButtonParam::GetKey(IParamBlock2 *pb, int idx)
{
// get the plKeys based on the texture map that the Texture map is on
Texmap* texmap = (Texmap* )pb->GetReferenceTarget(fID);
// make sure that there was a texmap set
if (texmap) {
plPlasmaMAXLayer *maxLayer = plPlasmaMAXLayer::GetPlasmaMAXLayer(texmap);
if (maxLayer != nullptr) {
// make sure the index is valid
if (idx >= 0 && idx < maxLayer->GetNumConversionTargets()) {
plLayerInterface* convertedLayer = maxLayer->GetConversionTarget(idx);
if (convertedLayer)
return convertedLayer->GetKey();
}
}
}

// otherwise we didn't find one, because of one of many reasons
return nullptr;
}

///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

plDropDownListParam::plDropDownListParam(ParamID id, ST::string name, std::vector<ST::string> options)
: plAutoUIParam(id, std::move(name)), fhList(), fOptions(std::move(options))
{
Expand Down
11 changes: 11 additions & 0 deletions Sources/MaxPlugin/MaxComponent/plAutoUIParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ class plPickMaterialAnimationButtonParam : public plPickButtonParam
void DestroyKeyArray();
};

class plPickLayerButtonParam : public plPickMaterialButtonParam
{
public:
plPickLayerButtonParam(ParamID id, ST::string name)
: plPickMaterialButtonParam(id, std::move(name))
{ }

int GetParamType() override { return kTypeLayer; }
plKey GetKey(IParamBlock2 *pb, int idx = 0) override;
};

class plDropDownListParam : public plAutoUIParam
{
protected:
Expand Down

0 comments on commit 5d31cb8

Please sign in to comment.