83 if (!validateFloats(msg)) {
84 setStatus(rviz_common::properties::StatusProperty::Error,
"Topic",
85 "Message contained invalid floating point values (nans or infs)");
89 rclcpp::Time msg_time(msg->header.stamp, RCL_ROS_TIME);
90 if (!updateFrame(msg->header.frame_id, msg_time)) {
91 setMissingTransformToFixedFrame(msg->header.frame_id);
99 Ogre::ColourValue base_color(
static_cast<float>(base_color_qt.redF()),
static_cast<float>(base_color_qt.greenF()),
100 static_cast<float>(base_color_qt.blueF()), 1.0f);
108 rviz_rendering::MaterialManager::enableAlphaBlending(
material_, std::min(alpha_bottom, alpha_top));
110 const size_t n = msg->polygon.points.size();
111 if (n < 2 || height <= 0.0f) {
120 unsigned int vertex_index = 0;
121 auto add_quad = [&](
const Ogre::Vector3& b0,
const Ogre::Vector3& b1,
const Ogre::Vector3& t1,
const Ogre::Vector3& t0) {
123 const unsigned int start_index = vertex_index;
125 Ogre::ColourValue bottom_color = base_color;
126 bottom_color.a = alpha_bottom;
127 Ogre::ColourValue top_color = base_color;
128 top_color.a = alpha_top;
140 manual_object_->triangle(start_index + 0, start_index + 1, start_index + 2);
141 manual_object_->triangle(start_index + 0, start_index + 2, start_index + 3);
145 const Ogre::Vector3 z_up(0.0f, 0.0f, 1.0f);
147 for (
size_t i = 0; i < n; ++i) {
148 const auto& p0 = msg->polygon.points[i];
149 const auto& p1 = msg->polygon.points[(i + 1) % n];
151 Ogre::Vector3 P0(p0.x, p0.y, p0.z);
152 Ogre::Vector3 P1(p1.x, p1.y, p1.z);
154 Ogre::Vector3 edge = P1 - P0;
155 Ogre::Vector3 edge_xy(edge.x, edge.y, 0.0f);
156 if (edge_xy.squaredLength() < 1e-10f) {
160 Ogre::Vector3 normal(-edge_xy.y, edge_xy.x, 0.0f);
162 const float hw = thickness * 0.5f;
165 Ogre::Vector3 B0 = P0;
166 Ogre::Vector3 B1 = P1;
167 Ogre::Vector3 T0 = P0 + height * z_up;
168 Ogre::Vector3 T1 = P1 + height * z_up;
170 if (thickness > 1e-6f) {
172 Ogre::Vector3 off = -normal * hw;
173 add_quad(B0 + off, B1 + off, T1 + off, T0 + off);
176 add_quad(B0 + off, B1 + off, T1 + off, T0 + off);
179 Ogre::Vector3 off = normal * 1e-3f;
180 add_quad(B0 - off, B1 - off, T1 - off, T0 - off);
181 add_quad(B0 + off, B1 + off, T1 + off, T0 + off);