MCPcopy Create free account
hub / github.com/defold/defold / SetGridShapeEnable

Function SetGridShapeEnable

engine/physics/src/physics/box2d/box2d_physics.cpp:1191–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189 }
1190
1191 bool SetGridShapeEnable(HCollisionObject2D collision_object, uint32_t shape_index, uint32_t enable)
1192 {
1193 Body* body = (Body*) collision_object;
1194 GridShapeData* shape_data = GetGridShapeData(body, shape_index);
1195 if (shape_data == 0)
1196 {
1197 return false;
1198 }
1199
1200 uint32_t num_cells = shape_data->m_RowCount * shape_data->m_ColumnCount;
1201 for (int i = 0; i < num_cells; ++i)
1202 {
1203 if (enable && !b2Shape_IsValid(shape_data->m_CellPolygonShapes[i]) && shape_data->m_Cells[i].m_Index != B2GRIDSHAPE_EMPTY_CELL)
1204 {
1205 CreateGridCellShape(collision_object, shape_index, i);
1206 }
1207 else if (!enable && b2Shape_IsValid(shape_data->m_CellPolygonShapes[i]))
1208 {
1209 b2DestroyShape(shape_data->m_CellPolygonShapes[i], false);
1210 memset(&shape_data->m_CellPolygonShapes[i], 0, sizeof(shape_data->m_CellPolygonShapes[i]));
1211 }
1212 }
1213
1214 return false;
1215 }
1216
1217 void SetCollisionObjectFilter(HCollisionObject2D collision_object,
1218 uint32_t shape, uint32_t child,

Callers 1

TYPED_TESTFunction · 0.50

Calls 4

GetGridShapeDataFunction · 0.85
b2Shape_IsValidFunction · 0.85
b2DestroyShapeFunction · 0.85
CreateGridCellShapeFunction · 0.70

Tested by 1

TYPED_TESTFunction · 0.40