-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement MDagPath #11
Conversation
Good question. There are subtle and not-so-subtle differences between the two, some of which I don't understand. # C++
MTransformationMatrix::addTranslation()
MTransformationMatrix::rotation() -> MQuaternion
# Python
MTransformationMatrix.translateBy()
MTransformationMatrix.rotation() -> MEulerRotation
# But whyyyy? They've made a few creative choices here, presumably to make it more user-friendly but it's so subjective.. I think we should stick to the C++ documentation as closely as possible and leave creative choices to the user. When that is not possible, such as.. // C++
MDagPath dagPath;
MFnDagNode(mobj).getPath(dagPath); ..where it's modifying a variable from a function rather than return a value (classic C++), we'll need to make some less-creative choices that I expect to become a predictable pattern anywhere this happens in C++. # Python
dagPath = MFnDagNode(mobj).getPath(dagPath) In this case, the reason they're doing it the way that they are in C++ is because they choose not to throw exceptions. Instead, they return a MDagPath dagPath;
MStatus status = MFnDagNode(mobj).getPath(dagPath);
if (status == MS::kSuccess) {
// It's ok to use dagPath
} With Python, I expect we'll be able to completely replace MStatus with exceptions.
Let's start there. I think it's hard to know until we have enough of a foundation to actually start using cmdc for actual code and experience what messages make the most sense given the context. At this point, some message is better than no message.
Yes, the API loves this. It's perfectly happy letting you continue working with bad memory and chooses to randomly crash on you whenever it feels like it instead. This is one of the things I'd like cmdc to get rid of. It's a bad habit. In this case, if the API isn't returning a bad MStatus, but we know for certain the value is bad, we should throw an exception ourselves to prevent the user from experiencing a crash. |
Nice, that all sounds good! It might be worth creating a |
Good idea! |
- fullPathName - getAPathTo
I've gotten rid of any MStatus checks here, It looks more consistent between methods that return a relevant status and those that don't. Since I'm not using MStatus anymore, I've changed the error message and reworded them to something I felt was more informative. |
src/MDagPath.inl
Outdated
MStatus status = MStatus(); | ||
MFn::Type type = self.apiType(&status); | ||
|
||
if (!status){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still test it, just in case there is some edge case whereby it does actually fail. We could test both, would be no harm in that.
Bah, looks like I commented on an old commit. But anyway, the MStatuses may not always return whether it fails, but it might sometimes. So we should probably still check it, alongside our extra checks. What do you think? |
Yeah, that sounds good to me |
Not quite done yet but I've implemented most methods now. A few questions:
|
There's lots of things missing in OM 2. I personally think we should include as much as humanly possible. I run into things missing in OM 2 far too often, many do, and it's one of the motivations behind writing a new binding. We don't have to implement everything at once though, so feel free to leave it for now if it slows you down.
I think this has to do with instances. Try making an instance of a transform, and it should return 2. |
The function is actually there in OM2 but not it the C++ API haha
That would make sense, I'll test that |
Oh haha, I misread. :D I could have sworn this was in the API because I'm using it all the time, but turns out it's actually called Maybe they moved that there, because it isn't exposed from it's original place? I haven't used it from Python before. That's an interesting point actually. I'm hoping we're able to avoid that, and actually expose it where it is in the C++ API rather than move stuff around. E.g. |
Not 100% sure I like that but how about "implementing" the method but just raising an error saying Main pro is that it helps people transition from OM2 easier Again, not really convinced by this, just throwing the idea out there |
I think we should stick to the C++ docs, that will be the beacon of light. Users with experience with the C++ API will be familiar with cmdc, and users of cmdc will become familiar with the C++ API. |
As soon as you're happy @Muream I'm happy to merge this and carry on! |
I've implemented s few more things during the week but the rest seems pretty low priority so I'm happy to leave that out yeah |
A few notes on what I've done and omitted:
Wasn't sure if I should have squashed all the commits or rebased the branch against master so I haven't done any of that. Let me know if you need me to do more work before merging this :) |
Good call.
Good point!
I think this looks good, great work. :) |
I've made it so that new tags generate a Maya module for all platforms and all Maya's. Can give it a try here: |
Nice, I only have 2022 installed but that loaded nicely there |
Yeah, me and GitHub Actions had an argument last night, and it won. Next time. :) |
This is not ready to be merged yet. I'm making the PR for visibility, and because I had a few questions.
My questions:
DagPath.extendToShape()
returns a reference to self in OM2 but not in the C++ API.I feel like not returning anything would make more sense since
self
is already modified by the methodI've just copied OM2's messages so far.
exclusiveMatrix
andexclusiveMatrixInverse
to fail when called from an invalid DagPath but they return an identity matrix instead.This seems consistent with OM2 but I'm not sure why they're not raising a RuntimeError where something like
childCount
does with a similar implementation