Skip to content

Commit

Permalink
MSharedPtr can only be used in Maya 2022+
Browse files Browse the repository at this point in the history
This fixes builds on Maya 2020 and below.
  • Loading branch information
david-cattermole committed Jun 16, 2024
1 parent bab8045 commit 752fe26
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/mmSolver/shape/ImagePlaneGeometry2Override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <maya/MGeometryExtractor.h>
#include <maya/MPxGeometryOverride.h>
#include <maya/MShaderManager.h>
#include <maya/MSharedPtr.h>
#include <maya/MUserData.h>

// MM Solver
Expand Down Expand Up @@ -99,10 +98,10 @@ ImagePlaneGeometry2Override::ImagePlaneGeometry2Override(const MObject &obj)
m_model_editor_changed_callback_id = MEventMessage::addEventCallback(
"modelEditorChanged",
ImagePlaneGeometry2Override::on_model_editor_changed_func, this);
#if MAYA_API_VERSION >= 20200000
#if MAYA_API_VERSION >= 20220000
m_shader_link_lost_user_data_ptr =
ShaderLinkLostUserData2Ptr(new ShaderLinkLostUserData2());
#elif
#else
m_shader_link_lost_user_data = ShaderLinkLostUserData2();
#endif
}
Expand Down
21 changes: 18 additions & 3 deletions src/mmSolver/shape/ImagePlaneGeometry2Override.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include <maya/MPxGeometryOverride.h>
#include <maya/MUserData.h>

#if MAYA_API_VERSION >= 20220000
#include <maya/MSharedPtr.h>
#endif

// MM Solver
#include <mmcore/lib.h>

Expand All @@ -51,7 +55,16 @@ namespace mmsolver {
class ShaderLinkLostUserData2 : public MUserData {
public:
ShaderLinkLostUserData2()
: MUserData(), link_lost_count(0), set_shader_count(0) {}
#if MAYA_API_VERSION >= 20220000
: MUserData()
#else
// MUserData(bool) constructor is deprecated in Maya 2022+
// because 'deleteAfterUse' is no longer needed.
: MUserData(true)
#endif
, link_lost_count(0)
, set_shader_count(0) {
}

// Keep track of the number of times stuff happens, just for
// interest sake (maybe to help debugging?) - doesn't really mean
Expand All @@ -60,7 +73,9 @@ class ShaderLinkLostUserData2 : public MUserData {
uint32_t set_shader_count;
};

#if MAYA_API_VERSION >= 20220000
using ShaderLinkLostUserData2Ptr = MSharedPtr<ShaderLinkLostUserData2>;
#endif

class ImagePlaneGeometry2Override : public MPxGeometryOverride {
public:
Expand Down Expand Up @@ -178,9 +193,9 @@ class ImagePlaneGeometry2Override : public MPxGeometryOverride {
MHWRender::MTexture *m_color_texture;
const MHWRender::MSamplerState *m_texture_sampler;

#if MAYA_API_VERSION >= 20200000
#if MAYA_API_VERSION >= 20220000
ShaderLinkLostUserData2Ptr m_shader_link_lost_user_data_ptr;
#elif
#else
ShaderLinkLostUserData2 m_shader_link_lost_user_data;
#endif
};
Expand Down
1 change: 0 additions & 1 deletion src/mmSolver/shape/ImagePlaneUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <maya/MGeometryExtractor.h>
#include <maya/MPxGeometryOverride.h>
#include <maya/MShaderManager.h>
#include <maya/MSharedPtr.h>
#include <maya/MUserData.h>

// MM Solver
Expand Down

0 comments on commit 752fe26

Please sign in to comment.