Workaround bounding boxes only for vehicles
This commit is contained in:
parent
a8505a2fb7
commit
44710c760d
|
@ -77,7 +77,6 @@
|
|||
|
||||
- `id`
|
||||
- `type_id`
|
||||
- `bounding_box`
|
||||
- `semantic_tags`
|
||||
- `is_alive`
|
||||
- `get_world()`
|
||||
|
@ -92,6 +91,7 @@
|
|||
|
||||
## `carla.Vehicle(carla.Actor)`
|
||||
|
||||
- `bounding_box`
|
||||
- `control`
|
||||
- `apply_control(vehicle_control)`
|
||||
- `set_autopilot(enabled=True)`
|
||||
|
|
|
@ -43,7 +43,6 @@ void export_actor() {
|
|||
// work-around, force return copy to resolve Actor instead of ActorState.
|
||||
.add_property("id", CALL_RETURNING_COPY(cc::Actor, GetId))
|
||||
.add_property("type_id", CALL_RETURNING_COPY(cc::Actor, GetTypeId))
|
||||
.add_property("bounding_box", CALL_RETURNING_COPY(cc::Actor, GetBoundingBox))
|
||||
.add_property("semantic_tags", &GetSemanticTags)
|
||||
.add_property("is_alive", CALL_RETURNING_COPY(cc::Actor, IsAlive))
|
||||
.def("get_world", CALL_RETURNING_COPY(cc::Actor, GetWorld))
|
||||
|
@ -59,6 +58,7 @@ void export_actor() {
|
|||
;
|
||||
|
||||
class_<cc::Vehicle, bases<cc::Actor>, boost::noncopyable, boost::shared_ptr<cc::Vehicle>>("Vehicle", no_init)
|
||||
.add_property("bounding_box", CALL_RETURNING_COPY(cc::Vehicle, GetBoundingBox))
|
||||
.add_property("control", CALL_RETURNING_COPY(cc::Vehicle, GetControl))
|
||||
.def("apply_control", &cc::Vehicle::ApplyControl, (arg("control")))
|
||||
.def("set_autopilot", &cc::Vehicle::SetAutopilot, (arg("enabled")=true))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "Carla/Server/TheNewCarlaServer.h"
|
||||
|
||||
#include "Carla/Sensor/Sensor.h"
|
||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||
|
||||
#include "GameFramework/SpectatorPawn.h"
|
||||
|
||||
|
@ -109,10 +110,15 @@ private:
|
|||
|
||||
carla::geom::BoundingBox GetActorBoundingBox(const AActor &Actor)
|
||||
{
|
||||
constexpr bool bOnlyCollidingComponents = true;
|
||||
FVector Origin, BoxExtent;
|
||||
Actor.GetActorBounds(bOnlyCollidingComponents, Origin, BoxExtent);
|
||||
return {Origin, BoxExtent};
|
||||
/// @todo Bounding boxes only available for vehicles.
|
||||
auto Vehicle = Cast<ACarlaWheeledVehicle>(&Actor);
|
||||
if (Vehicle != nullptr)
|
||||
{
|
||||
FVector Location = Vehicle->GetVehicleBoundingBoxTransform().GetTranslation();
|
||||
FVector Extent = Vehicle->GetVehicleBoundingBoxExtent();
|
||||
return {Location, Extent};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue