MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CM_TransposeGrid

Function CM_TransposeGrid

code/qcommon/cm_patch.cpp:233–275  ·  view source on GitHub ↗

================= CM_TransposeGrid Swaps the rows and columns in place ================= */

Source from the content-addressed store, hash-verified

231=================
232*/
233static void CM_TransposeGrid( cGrid_t *grid ) {
234 int i, j, l;
235 vec3_t temp;
236 qboolean tempWrap;
237
238 if ( grid->width > grid->height ) {
239 for ( i = 0 ; i < grid->height ; i++ ) {
240 for ( j = i + 1 ; j < grid->width ; j++ ) {
241 if ( j < grid->height ) {
242 // swap the value
243 VectorCopy( grid->points[i][j], temp );
244 VectorCopy( grid->points[j][i], grid->points[i][j] );
245 VectorCopy( temp, grid->points[j][i] );
246 } else {
247 // just copy
248 VectorCopy( grid->points[j][i], grid->points[i][j] );
249 }
250 }
251 }
252 } else {
253 for ( i = 0 ; i < grid->width ; i++ ) {
254 for ( j = i + 1 ; j < grid->height ; j++ ) {
255 if ( j < grid->width ) {
256 // swap the value
257 VectorCopy( grid->points[j][i], temp );
258 VectorCopy( grid->points[i][j], grid->points[j][i] );
259 VectorCopy( temp, grid->points[i][j] );
260 } else {
261 // just copy
262 VectorCopy( grid->points[i][j], grid->points[j][i] );
263 }
264 }
265 }
266 }
267
268 l = grid->width;
269 grid->width = grid->height;
270 grid->height = l;
271
272 tempWrap = grid->wrapWidth;
273 grid->wrapWidth = grid->wrapHeight;
274 grid->wrapHeight = tempWrap;
275}
276
277/*
278===================

Callers 1

CM_GeneratePatchCollideFunction · 0.70

Calls 1

VectorCopyFunction · 0.85

Tested by

no test coverage detected