• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "submesh.h"
16 
17 #include "entity_converting_value.h"
18 #include "util.h"
19 
SCENE_BEGIN_NAMESPACE()20 SCENE_BEGIN_NAMESPACE()
21 
22 bool SubMesh::InitDynamicProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path)
23 {
24     if (index_ == -1) {
25         CORE_LOG_E("Submesh index is uninitialised");
26         return false;
27     }
28     BASE_NS::string cpath = "MeshComponent.submeshes[" + BASE_NS::string(BASE_NS::to_string(index_)) + "]." + path;
29 
30     if (p->GetName() == "Material") {
31         auto ep = object_->CreateProperty(cpath).GetResult();
32         auto i = interface_cast<META_NS::IStackProperty>(p);
33         return ep && i &&
34                i->PushValue(META_NS::IValue::Ptr(
35                    new InterfacePtrEntityValue<IMaterial>(ep, { object_->GetScene(), ClassId::Material })));
36     }
37     return AttachEngineProperty(p, cpath);
38 }
39 
OnPropertyChanged(const META_NS::IProperty & p)40 void SubMesh::OnPropertyChanged(const META_NS::IProperty& p)
41 {
42     if (p.GetName() != "Name") {
43         META_NS::Invoke<META_NS::IOnChanged>(event_);
44     }
45 }
46 
47 SCENE_END_NAMESPACE()
48