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

Function compile_actor

src/resource/physics_resource.cpp:297–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295 }
296
297 s32 compile_actor(Buffer &output, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
298 {
299 CE_UNUSED_2(compiler, opts);
300
301 u32 flags = 0;
302 if (flat_json_object::has(obj, "data.lock_translation_x")) {
303 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_translation_x")));
304 flags |= lock ? ActorFlags::LOCK_TRANSLATION_X : 0u;
305 }
306 if (flat_json_object::has(obj, "data.lock_translation_y")) {
307 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_translation_y")));
308 flags |= lock ? ActorFlags::LOCK_TRANSLATION_Y : 0u;
309 }
310 if (flat_json_object::has(obj, "data.lock_translation_z")) {
311 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_translation_z")));
312 flags |= lock ? ActorFlags::LOCK_TRANSLATION_Z : 0u;
313 }
314 if (flat_json_object::has(obj, "data.lock_rotation_x")) {
315 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_rotation_x")));
316 flags |= lock ? ActorFlags::LOCK_ROTATION_X : 0u;
317 }
318 if (flat_json_object::has(obj, "data.lock_rotation_y")) {
319 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_rotation_y")));
320 flags |= lock ? ActorFlags::LOCK_ROTATION_Y : 0u;
321 }
322 if (flat_json_object::has(obj, "data.lock_rotation_z")) {
323 bool lock = RETURN_IF_ERROR(sjson::parse_bool(flat_json_object::get(obj, "data.lock_rotation_z")));
324 flags |= lock ? ActorFlags::LOCK_ROTATION_Z : 0u;
325 }
326
327 ActorResource ar;
328 ar.actor_class = RETURN_IF_ERROR(sjson::parse_string_id(flat_json_object::get(obj, "data.class")));
329 ar.mass = RETURN_IF_ERROR(sjson::parse_float (flat_json_object::get(obj, "data.mass")));
330 ar.flags = flags;
331 ar.collision_filter = RETURN_IF_ERROR(sjson::parse_string_id(flat_json_object::get(obj, "data.collision_filter")));
332 ar.material = RETURN_IF_ERROR(sjson::parse_string_id(flat_json_object::get(obj, "data.material")));
333
334 FileBuffer fb(output);
335 BinaryWriter bw(fb);
336 bw.write(ar.actor_class);
337 bw.write(ar.mass);
338 bw.write(ar.flags);
339 bw.write(ar.collision_filter);
340 bw.write(ar.material);
341 return 0;
342 }
343
344 s32 compile_mover(Buffer &output, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
345 {

Callers

nothing calls this directly

Calls 6

getFunction · 0.85
parse_string_idFunction · 0.85
hasFunction · 0.50
parse_boolFunction · 0.50
parse_floatFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected