#pragma once #include "sim.hpp" #include "utils.hpp" namespace madrona_gpudrive { void createPersistentEntities(Engine &ctx); void resetWorld(Engine &ctx); // Destroys all entities in the world void destroyWorld(Engine &ctx); static inline Action getZeroAction(DynamicsModel model) { switch (model) { case DynamicsModel::Classic: case DynamicsModel::InvertibleBicycle: { return Action{.classic = {0, 0, 0}}; break; } case DynamicsModel::DeltaLocal: { return Action{.delta{.dx = 0, .dy = 0, .dyaw = 0}}; } case DynamicsModel::State: { return Action{.state = {.position = madrona::math::Vector3{0, 0, 1}, .yaw = 0, .velocity = {.linear = madrona::math::Vector3::zero(), .angular = madrona::math::Vector3::zero()}}}; } default: return Action{.classic = {0, 0, 0}}; } } static inline void setRoadEntitiesProps(Engine &ctx, Entity road, madrona::math::Vector3 pos, madrona::math::Quat rot, Scale scale, EntityType type, ObjectID objId, ResponseType responseType, uint32_t roadIdx, MapType mapType) { ctx.get(road) = pos; ctx.get(road) = rot; ctx.get(road) = Velocity{madrona::math::Vector3::zero(), madrona::math::Vector3::zero()}; ctx.get(road) = scale; ctx.get(road) = type; ctx.get(road) = objId; ctx.get(road) = responseType; ctx.get(road).id = roadIdx; ctx.get(road) = mapType; ctx.get(ctx.get(road).e) = MapObservation{.position = pos.xy(), .scale = scale, .heading = utils::quatToYaw(rot), .type = (float)type, .id = static_cast(roadIdx), .mapType = static_cast(mapType)}; } } // namespace madrona_gpudrive