ousnius / nifly

C++ NIF library for the Gamebryo/NetImmerse File Format
GNU General Public License v3.0
52 stars 23 forks source link

Minor inconsistency of parameters in "Get/Set...ForShape" methods of NifFile class #30

Closed gavrant closed 2 years ago

gavrant commented 2 years ago

Almost all "Get/Set...ForShape" methods of NifFile class identify the shape by its pointer:

const std::vector<Vector3>* GetVertsForShape(NiShape* shape);
const std::vector<Vector3>* GetNormalsForShape(NiShape* shape);
and so on

But a couple of "Colors" methods go with the name of the shape instead:

const std::vector<Color4>* GetColorsForShape(const std::string& shapeName);
void SetColorsForShape(const std::string& shapeName, const std::vector<Color4>& colors);

And this is a bit confusing. I would suggest adding NiShape* shape overloads of these two for consistency and predictability.

ousnius commented 2 years ago

@gavrant There already is a function bool GetColorsForShape(NiShape* shape, std::vector<Color4>& outColors) const;

EDIT: It seems only SetColorsForShape is missing a pointer version.

gavrant commented 2 years ago

@ousnius Unfortunately for me, my code is a derivative of PyNifly, and PyNifly does this: const std::vector<Color4>* theColors = nif->GetColorsForShape(shape->name.get()); That is, uses the last remaining "named" method that got no pointer version with your commit. I guess I still need to rewrite that code to drop that rather shady shape->name.get() (especially with a .nif file with empty shape names I saw today).

ousnius commented 2 years ago

@ousnius Unfortunately for me, my code is a derivative of PyNifly, and PyNifly does this: const std::vector<Color4>* theColors = nif->GetColorsForShape(shape->name.get()); That is, uses the last remaining "named" method that got no pointer version with your commit. I guess I still need to rewrite that code to drop that rather shady shape->name.get() (especially with a .nif file with empty shape names I saw today).

nifly has all the functions you need (it did already for "Get", and does now for "Set"). You or someone else needs to update PyNifly to use the pointer versions as well.

gavrant commented 2 years ago

Yes, I know about the other version of GetColorsForShape that accepts a pointer instead of a string. It's just my inner perfectionist complaining about the sole remaining 'named" Get..ForShape in that block of code.