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

Function compile_mover

src/resource/physics_resource.cpp:344–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343
344 s32 compile_mover(Buffer &output, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
345 {
346 CE_UNUSED_2(compiler, opts);
347
348 MoverDesc md;
349 md.capsule.radius = RETURN_IF_ERROR(sjson::parse_float (flat_json_object::get(obj, "data.radius")));
350 md.capsule.height = RETURN_IF_ERROR(sjson::parse_float (flat_json_object::get(obj, "data.height")));
351 md.max_slope_angle = RETURN_IF_ERROR(sjson::parse_float (flat_json_object::get(obj, "data.max_slope_angle")));
352 if (flat_json_object::has(obj, "data.step_height")) {
353 md.step_height = RETURN_IF_ERROR(sjson::parse_float(flat_json_object::get(obj, "data.step_height")));
354 } else {
355 md.step_height = 0.5f;
356 }
357 md.collision_filter = RETURN_IF_ERROR(sjson::parse_string_id(flat_json_object::get(obj, "data.collision_filter")));
358 if (flat_json_object::has(obj, "data.center")) {
359 md.center = RETURN_IF_ERROR(sjson::parse_vector3(flat_json_object::get(obj, "data.center")));
360 } else {
361 md.center = VECTOR3_ZERO;
362 }
363
364 FileBuffer fb(output);
365 BinaryWriter bw(fb);
366 bw.write(md.capsule.radius);
367 bw.write(md.capsule.height);
368 bw.write(md.max_slope_angle);
369 bw.write(md.step_height);
370 bw.write(md.collision_filter);
371 bw.write(md.center);
372 return 0;
373 }
374
375 s32 joint_common_parse(JointDesc &jd, JointType::Enum jt, UnitCompiler &compiler, FlatJsonObject &obj, CompileOptions &opts)
376 {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected