MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetValue

Method SetValue

Source/Engine/Graphics/Materials/MaterialParams.cpp:171–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void MaterialParameter::SetValue(const Variant& value)
172{
173 bool invalidType = false;
174 switch (_type)
175 {
176 case MaterialParameterType::Bool:
177 _asBool = (bool)value;
178 break;
179 case MaterialParameterType::Integer:
180 case MaterialParameterType::SceneTexture:
181 case MaterialParameterType::ChannelMask:
182 case MaterialParameterType::TextureGroupSampler:
183 _asInteger = (int32)value;
184 break;
185 case MaterialParameterType::Float:
186 _asFloat = (float)value;
187 break;
188 case MaterialParameterType::Vector2:
189 _asVector2 = (Float2)value;
190 break;
191 case MaterialParameterType::Vector3:
192 _asVector3 = (Float3)value;
193 break;
194 case MaterialParameterType::Vector4:
195 *(Float4*)&AsData = (Float4)value;
196 break;
197 case MaterialParameterType::Color:
198 _asColor = (Color)value;
199 break;
200 case MaterialParameterType::Matrix:
201 *(Matrix*)&AsData = (Matrix)value;
202 break;
203 case MaterialParameterType::NormalMap:
204 case MaterialParameterType::Texture:
205 case MaterialParameterType::CubeTexture:
206 switch (value.Type.Type)
207 {
208 case VariantType::Null:
209 _asAsset = nullptr;
210 break;
211 case VariantType::Guid:
212 _asAsset = Content::LoadAsync<TextureBase>(*(Guid*)value.AsData);
213 break;
214 case VariantType::Pointer:
215 _asAsset = (TextureBase*)value.AsPointer;
216 break;
217 case VariantType::Object:
218 _asAsset = Cast<TextureBase>(value.AsObject);
219 invalidType = _asAsset == nullptr && value.AsObject != nullptr;
220 break;
221 case VariantType::Asset:
222 _asAsset = Cast<TextureBase>(value.AsAsset);
223 invalidType = _asAsset == nullptr && value.AsAsset != nullptr;
224 break;
225 default:
226 invalidType = true;
227 }
228 break;

Callers

nothing calls this directly

Calls 2

ToStringFunction · 0.50
ToStringMethod · 0.45

Tested by

no test coverage detected