| 149 | } |
| 150 | |
| 151 | void MjUtils::DrawDebugGeom(UWorld* World, const mjModel* m, const GeomView& geom_view, const FColor& DrawColor, float Multiplier) |
| 152 | { |
| 153 | if (!World || !m) |
| 154 | return; |
| 155 | |
| 156 | mjtNum* pos = geom_view.geom_xpos; |
| 157 | mjtNum* mat = geom_view.geom_xmat; |
| 158 | mjtNum* size = geom_view.geom_size; |
| 159 | |
| 160 | // Draw if group 3 (collision convention) OR if both contype and conaffinity are non-zero (active collider) |
| 161 | int group = geom_view._m->geom_group[geom_view.id]; |
| 162 | int contype = geom_view._m->geom_contype[geom_view.id]; |
| 163 | int conaffinity = geom_view._m->geom_conaffinity[geom_view.id]; |
| 164 | bool isCollisionGeom = (group == 3) || (contype != 0 && conaffinity != 0); |
| 165 | if (!isCollisionGeom) |
| 166 | { |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | FVector Position = MjToUEPosition(pos); |
| 171 | |
| 172 | mjtNum _quat[4]; |
| 173 | mju_mat2Quat(_quat, mat); |
| 174 | FQuat Rotation = MjToUERotation(_quat); |
| 175 | |
| 176 | switch (geom_view.geom_type) |
| 177 | { |
| 178 | case mjGEOM_BOX: |
| 179 | { |
| 180 | FColor Color = DrawColor != FColor::Magenta ? DrawColor : FColor::Cyan; |
| 181 | FVector Extent(size[0] * Multiplier, size[1] * Multiplier, size[2] * Multiplier); |
| 182 | DrawDebugBox(World, Position, Extent, Rotation, Color, false, -1, 0, 0.15f); |
| 183 | break; |
| 184 | } |
| 185 | case mjGEOM_SPHERE: |
| 186 | { |
| 187 | FColor Color = DrawColor != FColor::Magenta ? DrawColor : FColor::Green; |
| 188 | float Radius = size[0] * Multiplier; |
| 189 | DrawDebugSphere(World, Position, Radius, 16, Color, false, -1, 0, 0.15f); |
| 190 | break; |
| 191 | } |
| 192 | case mjGEOM_CAPSULE: |
| 193 | { |
| 194 | FColor Color = DrawColor != FColor::Magenta ? DrawColor : FColor::Yellow; |
| 195 | float Radius = size[0] * Multiplier; |
| 196 | float HalfHeight = size[1] * Multiplier; |
| 197 | DrawDebugCapsule(World, Position, HalfHeight + Radius, Radius, Rotation, Color, false, -1, 0, 0.15f); |
| 198 | break; |
| 199 | } |
| 200 | case mjGEOM_CYLINDER: |
| 201 | { |
| 202 | FColor Color = DrawColor != FColor::Magenta ? DrawColor : FColor::Orange; |
| 203 | float Radius = size[0] * Multiplier; |
| 204 | float HalfHeight = size[1] * Multiplier; |
| 205 | FVector UpVector = Rotation.GetAxisZ(); |
| 206 | FVector Start = Position - UpVector * HalfHeight; |
| 207 | FVector End = Position + UpVector * HalfHeight; |
| 208 | DrawDebugCylinder(World, Start, End, Radius, 16, Color, false, -1, 0, 0.15f); |
nothing calls this directly
no outgoing calls
no test coverage detected