Added toggle to select deterministic/physically based ragdoll animation.

This commit is contained in:
Axel 2020-11-26 12:09:24 +01:00 committed by Axel1092
parent b0cc977a8c
commit cba230bc0d
3 changed files with 20 additions and 6 deletions

View File

@ -37,8 +37,10 @@ namespace rpc {
int max_substeps = 10;
bool deterministic_ragdolls = true;
MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping,
max_substep_delta_time, max_substeps);
max_substep_delta_time, max_substeps, deterministic_ragdolls);
// =========================================================================
// -- Constructors ---------------------------------------------------------
@ -52,13 +54,15 @@ namespace rpc {
double fixed_delta_seconds = 0.0,
bool substepping = true,
double max_substep_delta_time = 0.01,
int max_substeps = 10)
int max_substeps = 10,
bool deterministic_ragdolls = true)
: synchronous_mode(synchronous_mode),
no_rendering_mode(no_rendering_mode),
fixed_delta_seconds(
fixed_delta_seconds > 0.0 ? fixed_delta_seconds : boost::optional<double>{}),
substepping(substepping),
max_substep_delta_time(max_substep_delta_time), max_substeps(max_substeps) {}
max_substep_delta_time(max_substep_delta_time), max_substeps(max_substeps),
deterministic_ragdolls(deterministic_ragdolls) {}
// =========================================================================
// -- Comparison operators -------------------------------------------------
@ -71,7 +75,8 @@ namespace rpc {
(substepping == rhs.substepping) &&
(fixed_delta_seconds == rhs.fixed_delta_seconds) &&
(max_substep_delta_time == rhs.max_substep_delta_time) &&
(max_substeps == rhs.max_substeps);
(max_substeps == rhs.max_substeps) &&
(deterministic_ragdolls == rhs.deterministic_ragdolls);
}
bool operator!=(const EpisodeSettings &rhs) const {
@ -91,7 +96,8 @@ namespace rpc {
Settings.FixedDeltaSeconds.Get(0.0),
Settings.bSubstepping,
Settings.MaxSubstepDeltaTime,
Settings.MaxSubsteps) {}
Settings.MaxSubsteps,
Settings.bDeterministicRagdolls) {}
operator FEpisodeSettings() const {
FEpisodeSettings Settings;
@ -103,6 +109,7 @@ namespace rpc {
Settings.bSubstepping = substepping;
Settings.MaxSubstepDeltaTime = max_substep_delta_time;
Settings.MaxSubsteps = max_substeps;
Settings.bDeterministicRagdolls = deterministic_ragdolls;
return Settings;
}

View File

@ -147,12 +147,14 @@ void export_world() {
arg("fixed_delta_seconds")=0.0,
arg("substepping")=true,
arg("max_substep_delta_time")=0.01,
arg("max_substeps")=10)))
arg("max_substeps")=10,
arg("deterministic_ragdolls")=false)))
.def_readwrite("synchronous_mode", &cr::EpisodeSettings::synchronous_mode)
.def_readwrite("no_rendering_mode", &cr::EpisodeSettings::no_rendering_mode)
.def_readwrite("substepping", &cr::EpisodeSettings::substepping)
.def_readwrite("max_substep_delta_time", &cr::EpisodeSettings::max_substep_delta_time)
.def_readwrite("max_substeps", &cr::EpisodeSettings::max_substeps)
.def_readwrite("deterministic_ragdolls", &cr::EpisodeSettings::deterministic_ragdolls)
.add_property("fixed_delta_seconds",
+[](const cr::EpisodeSettings &self) {
return OptionalToPythonObject(self.fixed_delta_seconds);
@ -277,6 +279,7 @@ void export_world() {
.def("cast_ray", CALL_RETURNING_LIST_2(cc::World, CastRay, cg::Location, cg::Location), (arg("initial_location"), arg("final_location")))
.def("project_point", CALL_RETURNING_OPTIONAL_3(cc::World, ProjectPoint, cg::Location, cg::Vector3D, float), (arg("location"), arg("direction"), arg("search_distance")=10000.f))
.def("ground_projection", CALL_RETURNING_OPTIONAL_2(cc::World, GroundProjection, cg::Location, float), (arg("location"), arg("search_distance")=10000.f))
.def(self_ns::str(self_ns::self))
;

View File

@ -27,4 +27,8 @@ struct CARLA_API FEpisodeSettings
double MaxSubstepDeltaTime = 0.01;
int MaxSubsteps = 10;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDeterministicRagdolls = true;
};