Skip to content
Snippets Groups Projects
Commit 3fad3f63 authored by Alecu100's avatar Alecu100
Browse files

fixed the complex shape to generate dismember partitions if the required data is provided

parent c6edbcf1
No related branches found
No related tags found
No related merge requests found
......@@ -306,7 +306,7 @@ public:
* Sets the association between the body parts and the faces in the complex shape
* \param[in] The new association meaning that the face at the position of the index corresponds to the body part group given by the value at the position of the index of the face
*/
NIFLIB_API void SetDismemberPartitionsFaces( vector<int> value );
NIFLIB_API void SetDismemberPartitionsFaces( const vector<int>& value );
/*
* Gets a list of the dismember groups
......@@ -318,7 +318,7 @@ public:
* Gets the association between the faces in the complex shape and the corresponding body parts
* \param[in] A list of the dismember groups;
*/
NIFLIB_API void SetDismemberPartitionsBodyParts( vector<BodyPartList> value);
NIFLIB_API void SetDismemberPartitionsBodyParts( const vector<BodyPartList>& value);
private:
vector<BodyPartList> dismemberPartitionsBodyParts;
......
......@@ -149,15 +149,19 @@ vector<int> ComplexShape::GetDismemberPartitionsFaces() const {
return dismemberPartitionsFaces;
}
void ComplexShape::SetDismemberPartitionsFaces( vector<int> value ) {
dismemberPartitionsFaces = value;
void ComplexShape::SetDismemberPartitionsFaces(const vector<int>& value ) {
dismemberPartitionsFaces.resize(value.size());
for(int i = 0; i < dismemberPartitionsFaces.size(); i++) {
dismemberPartitionsFaces[i] = value[i];
}
}
vector<BodyPartList> ComplexShape::GetDismemberPartitionsBodyParts() const {
return dismemberPartitionsBodyParts;
}
void ComplexShape::SetDismemberPartitionsBodyParts( vector<BodyPartList> value ) {
void ComplexShape::SetDismemberPartitionsBodyParts( const vector<BodyPartList>& value ) {
dismemberPartitionsBodyParts = value;
}
......@@ -787,11 +791,14 @@ Ref<NiAVObject> ComplexShape::Split( NiNode * parent, Matrix44 & transform, int
vector<Triangle> shapeTriangles;
//a vector that holds in what dismember groups or skin partition does each face belong
vector<BodyPartList> current_dismember_partitions;
vector<BodyPartList> current_dismember_partitions = dismemberPartitionsBodyParts;
//create a map betweem the faces and the dismember groups
vector<int> current_dismember_partitions_faces;
//since we might have dismember partitions the face index is also required
int current_face_index = 0;
//Loop through all faces, and all points on each face
//to set the vertices in the CompoundVertex list
for ( vector<ComplexFace>::const_iterator face = faces.begin(); face != faces.end(); ++face ) {
......@@ -887,18 +894,16 @@ Ref<NiAVObject> ComplexShape::Split( NiNode * parent, Matrix44 & transform, int
shapeTriangles.push_back(new_face);
//all the resulting triangles belong in the the same dismember partition or better said skin partition
current_dismember_partitions_faces.push_back(dismemberPartitionsFaces[i]);
current_dismember_partitions_faces.push_back(dismemberPartitionsFaces[current_face_index]);
}
}
}
current_face_index++;
}
//Clean up the dismember skin partitions
//if no face points to a certain dismember partition then that dismember partition must be removed
if(use_dismember_partitions == true) {
vector<bool> used_dismember_groups;
for(int x = 0; x < current_dismember_partitions.size(); x++) {
used_dismember_groups.push_back(false);
}
vector<bool> used_dismember_groups(current_dismember_partitions.size(), false);
for(int x = 0; x < current_dismember_partitions_faces.size(); x++) {
if(used_dismember_groups[current_dismember_partitions_faces[x]] == false) {
used_dismember_groups[current_dismember_partitions_faces[x]] = true;
......@@ -921,7 +926,7 @@ Ref<NiAVObject> ComplexShape::Split( NiNode * parent, Matrix44 & transform, int
}
//Attatch properties if any
//Check if the properties are skyrim specific in which case attach them in the 2 special slots
//Check if the properties are skyrim specific in which case attach them in the 2 special slots called bs_properties
if ( propGroups.size() > 0 ) {
BSLightingShaderPropertyRef shader_property = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment