Skip to content
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

Add missing public getters and setters to various classes #286

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
30 changes: 16 additions & 14 deletions Python/PRP/Avatar/pyClothingItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ PY_METHOD_VA(ClothingItem, getMesh,
"Params: lod\n"
"Gets the Key of the mesh for the specified LOD")
{
int lod = plClothingItem::kLODHigh;
if (!PyArg_ParseTuple(args, "i", &lod)) {
Py_ssize_t lod = plClothingItem::kLODHigh;
if (!PyArg_ParseTuple(args, "n", &lod)) {
PyErr_SetString(PyExc_TypeError, "getMesh expects int");
return nullptr;
}
Expand All @@ -41,10 +41,10 @@ PY_METHOD_VA(ClothingItem, setMesh,
"Params: lod, mesh\n"
"Sets the Key of the mesh for the specified LOD")
{
int lod = plClothingItem::kLODHigh;
Py_ssize_t lod = plClothingItem::kLODHigh;
pyKey* key;

if (!PyArg_ParseTuple(args, "iO", &lod, &key)) {
if (!PyArg_ParseTuple(args, "nO", &lod, &key)) {
PyErr_SetString(PyExc_TypeError, "setMesh expects int, plKey");
return nullptr;
}
Expand All @@ -61,8 +61,8 @@ PY_METHOD_VA(ClothingItem, getElementTexture,
"Params: element, layer\n"
"Gets the Key of the texture for the specified element and layer")
{
int element, layer;
if (!PyArg_ParseTuple(args, "ii", &element, &layer)) {
Py_ssize_t element, layer;
if (!PyArg_ParseTuple(args, "nn", &element, &layer)) {
PyErr_SetString(PyExc_TypeError, "getElementTexture expects int, int");
return nullptr;
}
Expand All @@ -74,10 +74,10 @@ PY_METHOD_VA(ClothingItem, setElementTexture,
"Params: element idx, layer idx, texture\n"
"Sets the texture of the specified element and layer")
{
int element, layer;
Py_ssize_t element, layer;
pyKey* key;

if (!PyArg_ParseTuple(args, "iiO", &element, &layer, &key)) {
if (!PyArg_ParseTuple(args, "nnO", &element, &layer, &key)) {
PyErr_SetString(PyExc_TypeError, "setElementTexture expects int, int, plKey");
return nullptr;
}
Expand All @@ -94,8 +94,8 @@ PY_METHOD_VA(ClothingItem, getElementName,
"Params: element idx\n"
"Gets the name of the specified element")
{
int element;
if (!PyArg_ParseTuple(args, "i", &element)) {
Py_ssize_t element;
if (!PyArg_ParseTuple(args, "n", &element)) {
PyErr_SetString(PyExc_TypeError, "getElementName expects int");
return nullptr;
}
Expand All @@ -107,9 +107,9 @@ PY_METHOD_VA(ClothingItem, setElementName,
"Params: element idx, name\n"
"Sets the name of the specified element")
{
int element;
Py_ssize_t element;
const char* name;
if (!PyArg_ParseTuple(args, "is", &element, &name)) {
if (!PyArg_ParseTuple(args, "ns", &element, &name)) {
PyErr_SetString(PyExc_TypeError, "setElementName expects int, string");
return nullptr;
}
Expand All @@ -136,8 +136,8 @@ PY_METHOD_VA(ClothingItem, delElement,
"Params: element idx\n"
"Remove an element from the clothingItem")
{
int idx;
if (!PyArg_ParseTuple(args, "i", &idx)) {
Py_ssize_t idx;
if (!PyArg_ParseTuple(args, "n", &idx)) {
PyErr_SetString(PyExc_TypeError, "delElement expects an int");
return nullptr;
}
Expand Down Expand Up @@ -176,6 +176,7 @@ PY_PROPERTY(plKey, ClothingItem, icon, getIcon, setIcon)
PY_PROPERTY(plKey, ClothingItem, accessory, getAccessory, setAccessory)
PY_PROPERTY(hsColorRGBA, ClothingItem, defaultTint1, getDefaultTint1, setDefaultTint1)
PY_PROPERTY(hsColorRGBA, ClothingItem, defaultTint2, getDefaultTint2, setDefaultTint2)
PY_PROPERTY_RO(ClothingItem, numElements, getNumElements)

PyGetSetDef pyClothingItem_GetSet[] = {
pyClothingItem_itemName_getset,
Expand All @@ -189,6 +190,7 @@ PyGetSetDef pyClothingItem_GetSet[] = {
pyClothingItem_accessory_getset,
pyClothingItem_defaultTint1_getset,
pyClothingItem_defaultTint2_getset,
pyClothingItem_numElements_getset,
PY_GETSET_TERMINATOR
};

Expand Down
1 change: 1 addition & 0 deletions Python/PyHSPlasma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@ class plClothingItem(hsKeyedObject):
group: int = ...
icon: Optional[plKey[plMipmap]] = ...
itemName: str = ...
numElements: int = ...
sortOrder: int = ...
tileset: int = ...
type: int = ...
Expand Down
9 changes: 9 additions & 0 deletions core/PRP/Audio/plEAXListenerMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ class HSPLASMA_EXPORT plEAXReverbEffect : public plEAXEffect
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
plKey getSoftRegion() const { return fSoftRegion; }
const EAXREVERBPROPERTIES& getListenerProps() const { return fListenerProps; }
EAXREVERBPROPERTIES& getListenerProps() { return fListenerProps; }
const std::vector<Aperture>& getApertures() const { return fApertures; }
std::vector<Aperture>& getApertures() { return fApertures; }

void setSoftRegion(plKey region) { fSoftRegion = std::move(region); }
};

#endif
8 changes: 8 additions & 0 deletions core/PRP/Avatar/plArmatureEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class HSPLASMA_EXPORT plArmatureEffectFootSound : public plArmatureEffect
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
const std::vector<plKey>& getMods() const { return fMods; }
std::vector<plKey>& getMods() { return fMods; }
};


Expand Down Expand Up @@ -67,6 +71,10 @@ class HSPLASMA_EXPORT plArmatureEffectsMgr : public hsKeyedObject
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
const std::vector<plKey>& getEffects() const { return fEffects; }
std::vector<plKey>& getEffects() { return fEffects; }
};

#endif
36 changes: 36 additions & 0 deletions core/PRP/Avatar/plArmatureMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ class HSPLASMA_EXPORT plArmatureModBase : public plAGMasterMod
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
const std::vector<plKey>& getMeshes() const { return fMeshKeys; }
std::vector<plKey>& getMeshes() { return fMeshKeys; }
const std::vector<std::vector<plKey>>& getUnusedBones() const { return fUnusedBones; }
std::vector<std::vector<plKey>>& getUnusedBones() { return fUnusedBones; }
const std::vector<plArmatureBrain*>& getBrains() const { return fBrains; }
std::vector<plArmatureBrain*>& getBrains() { return fBrains; }
plKey getDetector() const { return fDetector; }

void clearBrains();
void setDetector(plKey detector) { fDetector = std::move(detector); }
};


Expand Down Expand Up @@ -79,6 +88,33 @@ class HSPLASMA_EXPORT plArmatureMod : public plArmatureModBase
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
plKey getDefaultMesh() const { return fDefaultMesh; }
ST::string getRootName() const { return fRootName; }
plKey getClothingOutfit() const { return fClothingOutfit; }
int getBodyType() const { return fBodyType; }
plKey getEffects() const { return fEffects; }
hsVector3 getMins() const { return fMins; }
hsVector3 getMaxs() const { return fMaxs; }
float getPhysHeight() const { return fPhysHeight; }
float getPhysWidth() const { return fPhysWidth; }
ST::string getFootstepAge() const { return fFootstepAge; }
ST::string getFootstepPage() const { return fFootstepPage; }
ST::string getFootstepType() const { return fFootstepType; }

void setDefaultMesh(plKey defaultMesh) { fDefaultMesh = std::move(defaultMesh); }
void setRootName(ST::string rootName) { fRootName = std::move(rootName); }
void setClothingOutfit(plKey clothingOutfit) { fClothingOutfit = std::move(clothingOutfit); }
void setBodyType(int bodyType) { fBodyType = bodyType; }
void setEffects(plKey effects) { fEffects = std::move(effects); }
void setMins(hsVector3 mins) { fMins = mins; }
void setMaxs(hsVector3 maxs) { fMaxs = maxs; }
void setPhysHeight(float physHeight) { fPhysHeight = physHeight; }
void setPhysWidth(float physWidth) { fPhysWidth = physWidth; }
void setFootstepAge(ST::string footstepAge) { fFootstepAge = std::move(footstepAge); }
void setFootstepPage(ST::string footstepPage) { fFootstepPage = std::move(footstepPage); }
void setFootstepType(ST::string footstepType) { fFootstepType = std::move(footstepType); }
};


Expand Down
20 changes: 20 additions & 0 deletions core/PRP/Avatar/plAvatarClothing.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ class HSPLASMA_EXPORT plClothingOutfit : public plSynchedObject
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
unsigned char getGroup() const { return fGroup; }
plKey getBase() const { return fBase; }
plKey getTargetTexture() const { return fTargetTexture; }
plKey getMaterial() const { return fMaterial; }

void setGroup(unsigned char group) { fGroup = group; }
void setBase(plKey base) { fBase = std::move(base); }
void setTargetTexture(plKey targetTexture) { fTargetTexture = std::move(targetTexture); }
void setMaterial(plKey material) { fMaterial = std::move(material); }
};


Expand All @@ -71,6 +82,15 @@ class HSPLASMA_EXPORT plClothingBase : public hsKeyedObject
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
ST::string getName() const { return fName; }
ST::string getLayoutName() const { return fLayoutName; }
plKey getBaseTexture() const { return fBaseTexture; }

void setName(ST::string name) { fName = std::move(name); }
void setLayoutName(ST::string layoutName) { fLayoutName = std::move(layoutName); }
void setBaseTexture(plKey baseTexture) { fBaseTexture = std::move(baseTexture); }
};

#endif
2 changes: 1 addition & 1 deletion core/PRP/Avatar/plClothingItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void plClothingItem::addElement(const ST::string& elementName)
fTextures.push_back(new plKey[kLayerMax]);
}

void plClothingItem::delElement(int element)
void plClothingItem::delElement(size_t element)
{
delete[] fTextures[element];
fTextures.erase(fTextures.begin() + element);
Expand Down
17 changes: 10 additions & 7 deletions core/PRP/Avatar/plClothingItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class HSPLASMA_EXPORT plClothingItem : public hsKeyedObject
* at LOD of \a lodLevel.
* \sa LODLevels
*/
plKey getMesh(int lodLevel) const { return fMeshes[lodLevel]; }
plKey getMesh(size_t lodLevel) const { return fMeshes[lodLevel]; }

/** Returns the default first tint color for the item. */
hsColorRGBA getDefaultTint1() const
Expand Down Expand Up @@ -184,14 +184,17 @@ class HSPLASMA_EXPORT plClothingItem : public hsKeyedObject
* at LOD level \a lodLevel.
* \sa LODLevels
*/
void setMesh(int lodLevel, plKey mesh) { fMeshes[lodLevel] = std::move(mesh); }
void setMesh(size_t lodLevel, plKey mesh) { fMeshes[lodLevel] = std::move(mesh); }

/** Set the default first tint color for this item. */
void setDefaultTint1(const hsColorRGBA& tint);

/** Set the default second tint color for this item. */
void setDefaultTint2(const hsColorRGBA& tint);

/** Returns the number of elements in this clothing item. */
size_t getNumElements() const { return fElementNames.size(); }

/** Remove all elements from the clothing item. */
void clearElements();

Expand All @@ -203,15 +206,15 @@ class HSPLASMA_EXPORT plClothingItem : public hsKeyedObject
* to \a texture.
* \sa ClothingLayers
*/
void setElementTexture(int element, int layer, plKey texture)
void setElementTexture(size_t element, size_t layer, plKey texture)
{
fTextures[element][layer] = std::move(texture);
}

/**
* Sets the element name for element number \a element to \a elementName.
*/
void setElementName(int element, const ST::string& elementName)
void setElementName(size_t element, const ST::string& elementName)
{
fElementNames[element] = elementName;
}
Expand All @@ -221,21 +224,21 @@ class HSPLASMA_EXPORT plClothingItem : public hsKeyedObject
* \a layer.
* \sa ClothingLayers
*/
plKey getElementTexture(int element, int layer) const
plKey getElementTexture(size_t element, size_t layer) const
{
return fTextures[element][layer];
}

/**
* Returns the element name for element number \a element.
*/
ST::string getElementName(int element) const
ST::string getElementName(size_t element) const
{
return fElementNames[element];
}

/** Remove the specified element from the clothing item. */
void delElement(int element);
void delElement(size_t element);
};

#endif
3 changes: 3 additions & 0 deletions core/PRP/Geometry/plMorphArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class HSPLASMA_EXPORT plMorphArray
void write(hsStream* S, plResManager* mgr);
void prcWrite(pfPrcHelper* prc);
void prcParse(const pfPrcTag* tag, plResManager* mgr);

const std::vector<plMorphDelta>& getDeltas() const { return fDeltas; }
std::vector<plMorphDelta>& getDeltas() { return fDeltas; }
};

#endif
4 changes: 4 additions & 0 deletions core/PRP/Geometry/plMorphDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class HSPLASMA_EXPORT plMorphDataSet : public hsKeyedObject
protected:
void IPrcWrite(pfPrcHelper* prc) HS_OVERRIDE;
void IPrcParse(const pfPrcTag* tag, plResManager* mgr) HS_OVERRIDE;

public:
const std::vector<plMorphArray>& getMorphs() const { return fMorphs; }
std::vector<plMorphArray>& getMorphs() { return fMorphs; }
};

#endif
22 changes: 6 additions & 16 deletions core/PRP/Geometry/plMorphDelta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,15 @@ void plVertDelta::prcParse(const pfPrcTag* tag)


/* plMorphSpan */
plMorphSpan::~plMorphSpan()
{
delete[] fUVWs;
}

void plMorphSpan::read(hsStream* S)
{
fDeltas.resize(S->readInt());
fNumUVWChans = S->readInt();
delete[] fUVWs;
if (fNumUVWChans > 0)
fUVWs = new hsVector3[fNumUVWChans * fDeltas.size()];
else
fUVWs = nullptr;
fUVWs.resize(fNumUVWChans * fDeltas.size());

for (size_t i=0; i<fDeltas.size(); i++)
fDeltas[i].read(S);
for (size_t i=0; i<(fDeltas.size() * fNumUVWChans); i++)
for (size_t i=0; i<fUVWs.size(); i++)
fUVWs[i].read(S);
}

Expand All @@ -103,7 +94,7 @@ void plMorphSpan::write(hsStream* S)

for (size_t i=0; i<fDeltas.size(); i++)
fDeltas[i].write(S);
for (size_t i=0; i<(fDeltas.size() * fNumUVWChans); i++)
for (size_t i=0; i<fUVWs.size(); i++)
fUVWs[i].write(S);
}

Expand All @@ -119,7 +110,7 @@ void plMorphSpan::prcWrite(pfPrcHelper* prc)
prc->startTag("UVWs");
prc->writeParam("Channels", fNumUVWChans);
prc->endTag();
for (size_t i=0; i<(fDeltas.size() * fNumUVWChans); i++)
for (size_t i=0; i<fUVWs.size(); i++)
fUVWs[i].prcWrite(prc);
prc->closeTag();

Expand All @@ -141,14 +132,13 @@ void plMorphSpan::prcParse(const pfPrcTag* tag)
subchild = subchild->getNextSibling();
}
} else if (child->getName() == "UVWs") {
delete[] fUVWs;
fNumUVWChans = child->getParam("Channels", "0").to_uint();
size_t nUVWs = fDeltas.size() * fNumUVWChans;
if (child->countChildren() != nUVWs)
throw pfPrcParseException(__FILE__, __LINE__, "UVW count mismatch");
fUVWs = new hsVector3[nUVWs];
fUVWs.resize(nUVWs);
const pfPrcTag* subchild = child->getFirstChild();
for (size_t i=0; i<nUVWs; i++) {
for (size_t i=0; i<fUVWs.size(); i++) {
fUVWs[i].prcParse(subchild);
subchild = subchild->getNextSibling();
}
Expand Down
Loading
Loading