From c6edbcf109067b09f7985a913a6c4d5f6ce77cae Mon Sep 17 00:00:00 2001 From: Alecu100 <lui_alecu@yahoo.co.uk> Date: Wed, 15 Feb 2012 03:36:28 +0200 Subject: [PATCH] upgraded the complex shape to handle skyrim properties --- src/ComplexShape.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/ComplexShape.cpp b/src/ComplexShape.cpp index 8a469c76..16a6895c 100644 --- a/src/ComplexShape.cpp +++ b/src/ComplexShape.cpp @@ -19,6 +19,7 @@ All rights reserved. Please see niflib.h for license. */ #include "../include/gen/BodyPartList.h" #include "../include/obj/BSShaderTextureSet.h" #include "../include/obj/BSLightingShaderProperty.h" +#include "../include/obj/NiAlphaProperty.h" #include <stdlib.h> @@ -920,9 +921,33 @@ 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 if ( propGroups.size() > 0 ) { - for ( vector<NiPropertyRef>::const_iterator prop = propGroups[shape_num].begin(); prop != propGroups[shape_num].end(); ++prop ) { - shapes[shape_num]->AddProperty( *prop ); + BSLightingShaderPropertyRef shader_property = NULL; + + for(vector<NiPropertyRef>::const_iterator prop = propGroups[shape_num].begin(); prop != propGroups[shape_num].end(); ++prop ) { + NiPropertyRef current_property = *prop; + if(current_property->GetType().IsSameType(BSLightingShaderProperty::TYPE)) { + shader_property = DynamicCast<BSLightingShaderProperty>(current_property); + break; + } + } + + if(shader_property == NULL) { + for ( vector<NiPropertyRef>::const_iterator prop = propGroups[shape_num].begin(); prop != propGroups[shape_num].end(); ++prop ) { + shapes[shape_num]->AddProperty( *prop ); + } + } else { + NiAlphaPropertyRef alpha_property = NULL; + for ( vector<NiPropertyRef>::const_iterator prop = propGroups[shape_num].begin(); prop != propGroups[shape_num].end(); ++prop ) { + if ((*prop)->GetType().IsSameType(NiAlphaProperty::TYPE)) { + alpha_property = DynamicCast<NiAlphaProperty>((*prop)); + } + } + array<2, NiPropertyRef> bs_properties; + bs_properties[0] = shader_property; + bs_properties[1] = alpha_property; + shapes[shape_num]->setBsProperties(bs_properties); } } -- GitLab