-/* Maximum size of a single LM */
-#define MAX_SINGLE_LM_SIZE 256
-
-struct alloc_lm_row
-{
- int rowY;
- int currentX;
-};
-
-struct alloc_lm_state
-{
- int currentY;
- struct alloc_lm_row rows[MAX_SINGLE_LM_SIZE];
-};
-
-static void init_alloc_lm_state (struct alloc_lm_state* state)
-{
- int r;
-
- state->currentY = 0;
- for (r = 0; r < MAX_SINGLE_LM_SIZE; r++)
- {
- state->rows[r].currentX = 0;
- state->rows[r].rowY = -1;
- }
-}
-
-static qboolean Mod_Q1BSP_AllocLightmapBlock(struct alloc_lm_state* state, int totalwidth, int totalheight, int blockwidth, int blockheight, int *outx, int *outy)
-{
- struct alloc_lm_row* row;
- int r;
-
- row = &(state->rows[blockheight]);
- if ((row->rowY < 0) || (row->currentX + blockwidth > totalwidth))
- {
- if (state->currentY + blockheight <= totalheight)
- {
- row->rowY = state->currentY;
- row->currentX = 0;
- state->currentY += blockheight;
- }
- else
- {
- /* See if we can stuff the block into a higher row */
- row = NULL;
- for (r = blockheight; r < MAX_SINGLE_LM_SIZE; r++)
- {
- if ((state->rows[r].rowY >= 0)
- && (state->rows[r].currentX + blockwidth <= totalwidth))
- {
- row = &(state->rows[r]);
- break;
- }
- }
- if (row == NULL) return false;
- }
- }
- *outy = row->rowY;
- *outx = row->currentX;
- row->currentX += blockwidth;
-
- return true;
-}
-
-extern cvar_t gl_max_size;