当前位置: 首页>>代码示例>>C++>>正文


C++ GridBox::isZero方法代码示例

本文整理汇总了C++中GridBox::isZero方法的典型用法代码示例。如果您正苦于以下问题:C++ GridBox::isZero方法的具体用法?C++ GridBox::isZero怎么用?C++ GridBox::isZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridBox的用法示例。


在下文中一共展示了GridBox::isZero方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Grid_RecalcRouting

/**
 * @brief This function recalculates the routing surrounding the entity name.
 * @sa CM_InlineModel
 * @sa CM_CheckUnit
 * @sa CM_UpdateConnection
 * @sa CMod_LoadSubmodels
 * @sa Grid_RecalcBoxRouting
 * @param[in] mapTiles List of tiles the current (RMA-)map is composed of
 * @param[in] routing The routing map (either server or client map)
 * @param[in] name Name of the inline model to compute the mins/maxs for
 * @param[in] box The box around the inline model (alternative to name)
 * @param[in] list The local models list (a local model has a name starting with * followed by the model number)
 */
void Grid_RecalcRouting (mapTiles_t *mapTiles, Routing &routing, const char *name, const GridBox &box, const char **list)
{
    if (box.isZero()) {
        pos3_t min, max;
        vec3_t absmin, absmax;
        const cBspModel_t *model;
        unsigned int i;
        /* get inline model, if it is one */
        if (*name != '*') {
            Com_Printf("Called Grid_RecalcRouting with no inline model\n");
            return;
        }
        model = CM_InlineModel(mapTiles, name);
        if (!model) {
            Com_Printf("Called Grid_RecalcRouting with invalid inline model name '%s'\n", name);
            return;
        }

#if 1
        /* An attempt to fix the 'doors starting opened' bug (# 3456).
         * The main difference is the (missing) rotation of the halfVec.
         * The results are better, but do not fix the problem. */
        CalculateMinsMaxs(model->angles, model->mins, model->maxs, model->origin, absmin, absmax);
#else
        /* get the target model's dimensions */
        if (VectorNotEmpty(model->angles)) {
            vec3_t minVec, maxVec;
            vec3_t centerVec, halfVec, newCenterVec;
            vec3_t m[3];

            /* Find the center of the extents. */
            VectorCenterFromMinsMaxs(model->mins, model->maxs, centerVec);

            /* Find the half height and half width of the extents. */
            VectorSubtract(model->maxs, centerVec, halfVec);

            /* Rotate the center about the origin. */
            VectorCreateRotationMatrix(model->angles, m);
            VectorRotate(m, centerVec, newCenterVec);

            /* Set minVec and maxVec to bound around newCenterVec at halfVec size. */
            VectorSubtract(newCenterVec, halfVec, minVec);
            VectorAdd(newCenterVec, halfVec, maxVec);

            /* Now offset by origin then convert to position (Doors do not have 0 origins) */
            VectorAdd(minVec, model->origin, absmin);
            VectorAdd(maxVec, model->origin, absmax);
        } else {  /* normal */
            /* Now offset by origin then convert to position (Doors do not have 0 origins) */
            VectorAdd(model->mins, model->origin, absmin);
            VectorAdd(model->maxs, model->origin, absmax);
        }
#endif
        VecToPos(absmin, min);
        VecToPos(absmax, max);

        /* fit min/max into the world size */
        max[0] = std::min(max[0], (pos_t)(PATHFINDING_WIDTH - 1));
        max[1] = std::min(max[1], (pos_t)(PATHFINDING_WIDTH - 1));
        max[2] = std::min(max[2], (pos_t)(PATHFINDING_HEIGHT - 1));
        for (i = 0; i < 3; i++)
            min[i] = std::max(min[i], (pos_t)0);

        /* We now have the dimensions, call the generic rerouting function. */
        GridBox rerouteBox(min, max);
        Grid_RecalcBoxRouting(mapTiles, routing, rerouteBox, list);
    } else {
        /* use the passed box */
        Grid_RecalcBoxRouting(mapTiles, routing, box, list);
    }
}
开发者ID:ibrahimmusba,项目名称:ufoai,代码行数:84,代码来源:grid.cpp

示例2: Grid_RecalcRouting

/**
 * @brief This function recalculates the routing surrounding the entity name.
 * @sa CM_InlineModel
 * @sa CM_CheckUnit
 * @sa CM_UpdateConnection
 * @sa CMod_LoadSubmodels
 * @sa Grid_RecalcBoxRouting
 * @param[in] mapTiles List of tiles the current (RMA-)map is composed of
 * @param[in] routing The routing map (either server or client map)
 * @param[in] name Name of the inline model to compute the mins/maxs for
 * @param[in] box The box around the inline model (alternative to name)
 * @param[in] list The local models list (a local model has a name starting with * followed by the model number)
 */
void Grid_RecalcRouting (mapTiles_t* mapTiles, Routing& routing, const char* name, const GridBox& box, const char** list)
{
    if (box.isZero()) {
        /* get inline model, if it is one */
        if (*name != '*') {
            Com_Printf("Called Grid_RecalcRouting with no inline model\n");
            return;
        }
        const cBspModel_t* model = CM_InlineModel(mapTiles, name);
        if (!model) {
            Com_Printf("Called Grid_RecalcRouting with invalid inline model name '%s'\n", name);
            return;
        }

        AABB absbox;
#if 1
        /* An attempt to fix the 'doors starting opened' bug (# 3456).
         * The main difference is the (missing) rotation of the halfVec.
         * The results are better, but do not fix the problem. */
        CalculateMinsMaxs(model->angles, model->cbmBox, model->origin, absbox);
#else
        /* get the target model's dimensions */
        if (VectorNotEmpty(model->angles)) {
            vec3_t minVec, maxVec;
            vec3_t centerVec, halfVec, newCenterVec;
            vec3_t m[3];

            /* Find the center of the extents. */
            model->cbmBox.getCenter(centerVec);

            /* Find the half height and half width of the extents. */
            VectorSubtract(model->cbmBox.maxs, centerVec, halfVec);

            /* Rotate the center about the origin. */
            VectorCreateRotationMatrix(model->angles, m);
            VectorRotate(m, centerVec, newCenterVec);

            /* Set minVec and maxVec to bound around newCenterVec at halfVec size. */
            VectorSubtract(newCenterVec, halfVec, minVec);
            VectorAdd(newCenterVec, halfVec, maxVec);

            /* Now offset by origin then convert to position (Doors do not have 0 origins) */
            absbox.set(minVec, maxVec);
            absbox.shift(model->origin);
        } else {  /* normal */
            /* Now offset by origin then convert to position (Doors do not have 0 origins) */
            absbox.set(model->cbmBox);
            absbox.shift(model->origin);
        }
#endif
        GridBox rerouteBox(absbox);

        /* fit min/max into the world size */
        rerouteBox.clipToMaxBoundaries();

        /* We now have the dimensions, call the generic rerouting function. */
        Grid_RecalcBoxRouting(mapTiles, routing, rerouteBox, list);
    } else {
        /* use the passed box */
        Grid_RecalcBoxRouting(mapTiles, routing, box, list);
    }
}
开发者ID:cigo,项目名称:ufoai,代码行数:75,代码来源:grid.cpp


注:本文中的GridBox::isZero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。