MCPcopy Create free account
hub / github.com/crownengine/crown / compile_mesh_renderer

Function compile_mesh_renderer

src/resource/unit_compiler.cpp:167–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167static s32 compile_mesh_renderer(Buffer &output, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
168{
169 CE_UNUSED(compiler);
170
171 TempAllocator4096 ta;
172 DynamicString mesh_resource(ta);
173 RETURN_IF_ERROR(sjson::parse_string(mesh_resource, flat_json_object::get(obj, "data.mesh_resource")));
174
175 WARN_IF_MISSING(UNIT_COMPILER, "mesh", mesh_resource.c_str(), opts);
176 opts.add_requirement("mesh", mesh_resource.c_str());
177
178 DynamicString material(ta);
179 RETURN_IF_ERROR(sjson::parse_string(material, flat_json_object::get(obj, "data.material")));
180 WARN_IF_MISSING(UNIT_COMPILER, "material"
181 , material.c_str()
182 , opts
183 );
184 opts.add_requirement("material", material.c_str());
185
186 MeshRendererDesc mrd;
187 mrd.mesh_resource = RETURN_IF_ERROR(sjson::parse_resource_name(flat_json_object::get(obj, "data.mesh_resource")));
188 mrd.material_resource = RETURN_IF_ERROR(sjson::parse_resource_name(flat_json_object::get(obj, "data.material")));
189 mrd.geometry_name = RETURN_IF_ERROR(sjson::parse_string_id (flat_json_object::get(obj, "data.geometry_name")));
190 mrd.flags = 0u;
191 {
192 bool visible = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.visible")));
193 mrd.flags |= visible ? RenderableFlags::VISIBLE : 0u;
194 }
195 if (flat_json_object::has(obj, "data.cast_shadows")) {
196 bool cast_shadows = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.cast_shadows")));
197 mrd.flags |= cast_shadows ? RenderableFlags::SHADOW_CASTER : 0u;
198 } else {
199 mrd.flags |= RenderableFlags::SHADOW_CASTER;
200 }
201
202 FileBuffer fb(output);
203 BinaryWriter bw(fb);
204 bw.write(mrd.mesh_resource);
205 bw.write(mrd.material_resource);
206 bw.write(mrd.geometry_name);
207 bw.write(mrd.flags);
208 return 0;
209}
210
211static s32 compile_sprite_renderer(Buffer &output, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
212{

Callers

nothing calls this directly

Calls 9

getFunction · 0.85
parse_resource_nameFunction · 0.85
parse_string_idFunction · 0.85
add_requirementMethod · 0.80
parse_stringFunction · 0.50
parse_boolFunction · 0.50
hasFunction · 0.50
c_strMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected