Add engine-internal convenience macro for allocating typed arrays, improve error message.
PiperOrigin-RevId: 705126655 Change-Id: I2bd8fada6d33a919d2fb82297f93ac57958355a4
This commit is contained in:
committed by
Copybara-Service
parent
3ca97248a3
commit
2691887500
@@ -426,14 +426,14 @@ void mj_island(const mjModel* m, mjData* d) {
|
||||
|
||||
// allocate edge array
|
||||
int nedge_max = countMaxEdge(m, d);
|
||||
int* edge = mj_stackAllocInt(d, 2*nedge_max);
|
||||
int* edge = mjSTACKALLOC(d, 2*nedge_max, int);
|
||||
|
||||
// get tree-tree edges and rownnz counts from efc arrays
|
||||
int* rownnz = mj_stackAllocInt(d, ntree); // number of edges per tree
|
||||
int* rownnz = mjSTACKALLOC(d, ntree, int); // number of edges per tree
|
||||
int nedge = findEdges(m, d, rownnz, edge, nedge_max);
|
||||
|
||||
// compute starting address of tree's column indices while resetting rownnz
|
||||
int* rowadr = mj_stackAllocInt(d, ntree);
|
||||
int* rowadr = mjSTACKALLOC(d, ntree, int);
|
||||
rowadr[0] = 0;
|
||||
for (int r=1; r < ntree; r++) {
|
||||
rowadr[r] = rowadr[r-1] + rownnz[r-1];
|
||||
@@ -442,7 +442,7 @@ void mj_island(const mjModel* m, mjData* d) {
|
||||
rownnz[ntree-1] = 0;
|
||||
|
||||
// copy column indices: list each tree's neighbors
|
||||
int* colind = mj_stackAllocInt(d, nedge);
|
||||
int* colind = mjSTACKALLOC(d, nedge, int);
|
||||
for (int e=0; e < nedge; e++) {
|
||||
int row = edge[2*e];
|
||||
int col = edge[2*e + 1];
|
||||
@@ -450,8 +450,8 @@ void mj_island(const mjModel* m, mjData* d) {
|
||||
}
|
||||
|
||||
// discover islands
|
||||
int* tree_island = mj_stackAllocInt(d, ntree); // id of island assigned to tree
|
||||
int* stack = mj_stackAllocInt(d, nedge);
|
||||
int* tree_island = mjSTACKALLOC(d, ntree, int); // id of island assigned to tree
|
||||
int* stack = mjSTACKALLOC(d, nedge, int);
|
||||
d->nisland = mj_floodFill(tree_island, ntree, rownnz, rowadr, colind, stack);
|
||||
|
||||
// allocate island arrays on arena
|
||||
|
||||
Reference in New Issue
Block a user