diff --git a/src/naveditor/InputGeom.cpp b/src/naveditor/InputGeom.cpp index ed072081..8545fbce 100644 --- a/src/naveditor/InputGeom.cpp +++ b/src/naveditor/InputGeom.cpp @@ -728,10 +728,10 @@ void InputGeom::drawOffMeshConnections(duDebugDraw* dd, const float* offset, boo dd->depthMask(true); } -void InputGeom::addBoxVolume(const float* bmin, const float* bmax, +int InputGeom::addBoxVolume(const float* bmin, const float* bmax, unsigned short flags, unsigned char area) { - if (m_volumeCount >= MAX_VOLUMES) return; + if (m_volumeCount >= MAX_VOLUMES) return -1; ShapeVolume* vol = &m_volumes[m_volumeCount++]; rdVcopy(&vol->verts[0], bmin); rdVcopy(&vol->verts[3], bmax); @@ -741,12 +741,14 @@ void InputGeom::addBoxVolume(const float* bmin, const float* bmax, vol->flags = flags; vol->area = area; vol->type = VOLUME_BOX; + + return m_volumeCount-1; } -void InputGeom::addCylinderVolume(const float* pos, const float radius, +int InputGeom::addCylinderVolume(const float* pos, const float radius, const float height, unsigned short flags, unsigned char area) { - if (m_volumeCount >= MAX_VOLUMES) return; + if (m_volumeCount >= MAX_VOLUMES) return -1; ShapeVolume* vol = &m_volumes[m_volumeCount++]; rdVcopy(vol->verts, pos); vol->verts[3] = radius; @@ -757,12 +759,14 @@ void InputGeom::addCylinderVolume(const float* pos, const float radius, vol->flags = flags; vol->area = area; vol->type = VOLUME_CYLINDER; + + return m_volumeCount-1; } -void InputGeom::addConvexVolume(const float* verts, const int nverts, +int InputGeom::addConvexVolume(const float* verts, const int nverts, const float minh, const float maxh, unsigned short flags, unsigned char area) { - if (m_volumeCount >= MAX_VOLUMES) return; + if (m_volumeCount >= MAX_VOLUMES) return -1; ShapeVolume* vol = &m_volumes[m_volumeCount++]; memcpy(vol->verts, verts, sizeof(float)*3*nverts); vol->hmin = minh; @@ -771,6 +775,8 @@ void InputGeom::addConvexVolume(const float* verts, const int nverts, vol->flags = flags; vol->area = area; vol->type = VOLUME_CONVEX; + + return m_volumeCount-1; } void InputGeom::deleteConvexVolume(int i) diff --git a/src/naveditor/ShapeVolumeTool.cpp b/src/naveditor/ShapeVolumeTool.cpp index 994fdf82..29a87096 100644 --- a/src/naveditor/ShapeVolumeTool.cpp +++ b/src/naveditor/ShapeVolumeTool.cpp @@ -368,14 +368,14 @@ void ShapeVolumeTool::handleClick(const float* /*s*/, const float* p, const int bmin[2] -= m_boxDescent; bmax[2] += m_boxAscent; - geom->addBoxVolume(&m_pts[0*3], &m_pts[1*3], (unsigned short)m_polyFlags, (unsigned char)m_areaType); + m_selectedVolumeIndex = geom->addBoxVolume(&m_pts[0*3], &m_pts[1*3], (unsigned short)m_polyFlags, (unsigned char)m_areaType); m_npts = 0; m_nhull = 0; } break; case VOLUME_CYLINDER: - geom->addCylinderVolume(p, m_cylinderRadius, m_cylinderHeight, (unsigned short)m_polyFlags, (unsigned char)m_areaType); + m_selectedVolumeIndex = geom->addCylinderVolume(p, m_cylinderRadius, m_cylinderHeight, (unsigned short)m_polyFlags, (unsigned char)m_areaType); break; case VOLUME_CONVEX: // If clicked on that last pt, create the shape. @@ -399,11 +399,11 @@ void ShapeVolumeTool::handleClick(const float* /*s*/, const float* p, const int float offset[MAX_SHAPEVOL_PTS*2*3]; const int noffset = rcOffsetPoly(verts, m_nhull, m_convexOffset, offset, MAX_SHAPEVOL_PTS*2); if (noffset > 0) - geom->addConvexVolume(offset, noffset, minh, maxh, (unsigned short)m_polyFlags, (unsigned char)m_areaType); + m_selectedVolumeIndex = geom->addConvexVolume(offset, noffset, minh, maxh, (unsigned short)m_polyFlags, (unsigned char)m_areaType); } else { - geom->addConvexVolume(verts, m_nhull, minh, maxh, (unsigned short)m_polyFlags, (unsigned char)m_areaType); + m_selectedVolumeIndex = geom->addConvexVolume(verts, m_nhull, minh, maxh, (unsigned short)m_polyFlags, (unsigned char)m_areaType); } } diff --git a/src/naveditor/include/InputGeom.h b/src/naveditor/include/InputGeom.h index 075f6078..d2ae1eb1 100644 --- a/src/naveditor/include/InputGeom.h +++ b/src/naveditor/include/InputGeom.h @@ -191,11 +191,11 @@ public: ///@{ int getConvexVolumeCount() const { return m_volumeCount; } // todo(amos): rename to 'getShapeVolumeCount' ShapeVolume* getConvexVolumes() { return m_volumes; } // todo(amos): rename to 'getShapeVolumes' - void addBoxVolume(const float* bmin, const float* bmax, + int addBoxVolume(const float* bmin, const float* bmax, unsigned short flags, unsigned char area); - void addCylinderVolume(const float* pos, const float radius, + int addCylinderVolume(const float* pos, const float radius, const float height, unsigned short flags, unsigned char area); - void addConvexVolume(const float* verts, const int nverts, + int addConvexVolume(const float* verts, const int nverts, const float minh, const float maxh, unsigned short flags, unsigned char area); void deleteConvexVolume(int i); // todo(amos): rename to 'deleteShapeVolumes' void drawBoxVolumes(struct duDebugDraw* dd, const float* offset, const int hilightIdx = -1);