Ejemplo n.º 1
0
void handle_comment(char c)  { PUSH_ARRAY(comment, c);  }
Ejemplo n.º 2
0
internal void initialize_memory( PermanentState *permanent, Node16Arena *node16, RenderState *renderer, Memory* memory) {
    permanent->dynamic_blocks     = (StaticBlock*) PUSH_ARRAY(&permanent->arena, (16384), StaticBlock);
    permanent->static_blocks      = (StaticBlock*) PUSH_ARRAY(&permanent->arena, (16384), StaticBlock);
    permanent->transparent_blocks = (StaticBlock*) PUSH_ARRAY(&permanent->arena, (16384), StaticBlock);
    permanent->actors             = (Actor*) PUSH_ARRAY(&permanent->arena, (16384*4), Actor);
    permanent->paths              = (ActorPath*) PUSH_ARRAY(&permanent->arena, (16384*4), ActorPath);
    permanent->steer_data         = (ActorSteerData*) PUSH_ARRAY(&permanent->arena, (16384*4), ActorSteerData);
    for (int i = 0; i < 16384*4; i++) {
        permanent->steer_data[i].mass      = 1.0f;
        permanent->steer_data[i].max_force = 10;
        permanent->steer_data[i].max_speed = 50 + rand_float() * 80;
    }
    permanent->anim_data = (ActorAnimData*) PUSH_ARRAY(&permanent->arena, (16384*4), ActorAnimData);

    for (int i = 0; i < 16384*4; i++) {
        permanent->anim_data[i].frame = 4;
    }
    for (int i = 0; i < 16384*4; i++) {
        Node16 *Sentinel = (Node16 *) PUSH_STRUCT(&node16->arena, Node16);
        permanent->paths[i].Sentinel            = Sentinel;
        permanent->paths[i].Sentinel->Next      = Sentinel;
        permanent->paths[i].Sentinel->Prev      = Sentinel;
        permanent->actors[i].index              = i;
        permanent->paths[i].Sentinel->path.node = Vector3Make(-999,-999,-999);
    }

    node16->Free = PUSH_STRUCT(&node16->arena, Node16);
    node16->Free->Next = node16->Free;
    node16->Free->Prev = node16->Free;

    permanent->glyphs = (Glyph*) PUSH_ARRAY(&permanent->arena, (16384), Glyph);
    permanent->colored_lines = (ColoredLine*) PUSH_ARRAY(&permanent->arena, (16384), ColoredLine);

    BlockTextureAtlasPosition texture_atlas_data[BlockTotal];
    fill_generated_values(generated_frames);
    fill_generated_complex_values(generated_body_frames);

    texture_atlas_data[Floor]        = convertSimpleFrameToBlockTexturePos(generated_frames[BL_floor_000], 0, 0);
    texture_atlas_data[WallBlock]    = convertSimpleFrameToBlockTexturePos(generated_frames[BL_wall_000], 0, 0);
    texture_atlas_data[WindowBlock]  = convertSimpleFrameToBlockTexturePos(generated_frames[BL_window_000], 0, 0);
    texture_atlas_data[LadderUp]     = convertSimpleFrameToBlockTexturePos(generated_frames[BL_ladder_up_000], 0, 0);
    texture_atlas_data[LadderUpDown] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_ladder_up_down_000], 0, 0);
    texture_atlas_data[LadderDown]   = convertSimpleFrameToBlockTexturePos(generated_frames[BL_ladder_down_000], 0, 0);

    texture_atlas_data[EscalatorDown1S] = texture_atlas_data[EscalatorUp1S] = texture_atlas_data[Stairs1S] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_south_up_000], 0, 0);
    texture_atlas_data[EscalatorDown2S] = texture_atlas_data[EscalatorUp2S] = texture_atlas_data[Stairs2S] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_south_up_000], 0, 24);
    texture_atlas_data[EscalatorDown3S] = texture_atlas_data[EscalatorUp3S] = texture_atlas_data[Stairs3S] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_south_up_000], 0, 48);
    texture_atlas_data[EscalatorDown4S] = texture_atlas_data[EscalatorUp4S] = texture_atlas_data[Stairs4S] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_south_up_000], 0, 72);

    texture_atlas_data[EscalatorDown1N] = texture_atlas_data[EscalatorUp1N] = texture_atlas_data[Stairs1N] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_north_up_000], 0, 0);
    texture_atlas_data[EscalatorDown2N] = texture_atlas_data[EscalatorUp2N] = texture_atlas_data[Stairs2N] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_north_up_000], 0, 24);
    texture_atlas_data[EscalatorDown3N] = texture_atlas_data[EscalatorUp3N] = texture_atlas_data[Stairs3N] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_north_up_000], 0, 48);
    texture_atlas_data[EscalatorDown4N] = texture_atlas_data[EscalatorUp4N] = texture_atlas_data[Stairs4N] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_north_up_000], 0, 72);

    texture_atlas_data[EscalatorDown1W] = texture_atlas_data[EscalatorUp1W] = texture_atlas_data[Stairs1W] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_west_up_000], 0, 0);
    texture_atlas_data[EscalatorDown2W] = texture_atlas_data[EscalatorUp2W] = texture_atlas_data[Stairs2W] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_west_up_000], 0, 24);
    texture_atlas_data[EscalatorDown3W] = texture_atlas_data[EscalatorUp3W] = texture_atlas_data[Stairs3W] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_west_up_000], 0, 48);
    texture_atlas_data[EscalatorDown4W] = texture_atlas_data[EscalatorUp4W] = texture_atlas_data[Stairs4W] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_west_up_000], 0, 72);

    texture_atlas_data[EscalatorDown1E] = texture_atlas_data[EscalatorUp1E] = texture_atlas_data[Stairs1E] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_east_up_000], 0, 0  );
    texture_atlas_data[EscalatorDown2E] = texture_atlas_data[EscalatorUp2E] = texture_atlas_data[Stairs2E] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_east_up_000], 0, 24 );
    texture_atlas_data[EscalatorDown3E] = texture_atlas_data[EscalatorUp3E] = texture_atlas_data[Stairs3E] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_east_up_000], 0, 48 );
    texture_atlas_data[EscalatorDown4E] = texture_atlas_data[EscalatorUp4E] = texture_atlas_data[Stairs4E] = convertSimpleFrameToBlockTexturePos(generated_frames[BL_escalator_east_up_000], 0, 72 );

    int used_static_block_count = 0;
    int used_dynamic_block_count = 0;
    int used_transparent_block_count = 0;

    for (u32 z = 0; z < permanent->dims.z_level ; z++){
        for (u32 y = 0; y< permanent->dims.y; y++){
            for (u32 x = 0; x< permanent->dims.x; x++){
                WorldBlock *b = &permanent->level.blocks[FLATTEN_3D_INDEX(x,y,z,permanent->dims.x, permanent->dims.y)];


                u32 x_ = getRotatedXInt(x, y, facing_side, permanent->dims);
                u32 y_ = getRotatedYInt(x, y, facing_side, permanent->dims);
                Block block = getRotatedBlock(b->object, facing_side);


                permanent->static_blocks[used_static_block_count].is_floor = 0;
                switch (block){
                case WindowBlock:
                    add_transparent_block(x_, y_, z, permanent, &used_transparent_block_count, texture_atlas_data[block]);
                    used_transparent_block_count++;
                    break;

                case WallBlock:
                case LadderUpDown:
                case LadderUp:
                case LadderDown:
                    add_static_block(x_, y_, z, permanent, &used_static_block_count, texture_atlas_data[block]);
                    used_static_block_count++;
                    break;

                case Floor:
                case Stairs1N: case Stairs2N: case Stairs3N: case Stairs4N:
                case Stairs1E: case Stairs2E: case Stairs3E: case Stairs4E:
                case Stairs1S: case Stairs2S: case Stairs3S: case Stairs4S:
                case Stairs1W: case Stairs2W: case Stairs3W: case Stairs4W:
                    add_static_block(x_, y_, z, permanent, &used_static_block_count, texture_atlas_data[block]);
                    permanent->static_blocks[used_static_block_count].is_floor = 1;
                    used_static_block_count++;
                    break;

                case EscalatorUp1N: case EscalatorUp2N: case EscalatorUp3N: case EscalatorUp4N:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_north_up_000, BL_escalator_north_up_011, 0.5f/12, 1);
                    used_dynamic_block_count++;
                    break;
                case EscalatorDown1N: case EscalatorDown2N: case EscalatorDown3N: case EscalatorDown4N:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_north_up_000, BL_escalator_north_up_011, 0.5f/12, 0);
                    used_dynamic_block_count++;
                    break;
                case EscalatorUp1E: case EscalatorUp2E: case EscalatorUp3E: case EscalatorUp4E:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_east_up_000, BL_escalator_east_up_007, 0.5f/8, 1);
                    used_dynamic_block_count++;
                    break;
                case EscalatorDown1E: case EscalatorDown2E: case EscalatorDown3E: case EscalatorDown4E:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block],  BL_escalator_east_up_000,  BL_escalator_east_up_007, 0.5f/8, 0);
                    used_dynamic_block_count++;
                    break;
                case EscalatorUp1W: case EscalatorUp2W: case EscalatorUp3W: case EscalatorUp4W:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_west_up_000, BL_escalator_west_up_007, 0.5f/8, 1);
                    used_dynamic_block_count++;
                    break;
                case EscalatorDown1W: case EscalatorDown2W: case EscalatorDown3W: case EscalatorDown4W:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_west_up_000, BL_escalator_west_up_007, 0.5f/8, 0);
                    used_dynamic_block_count++;
                    break;
                case EscalatorUp1S: case EscalatorUp2S: case EscalatorUp3S: case EscalatorUp4S:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_south_up_000, BL_escalator_south_up_007, 0.5f/8, 1);
                    used_dynamic_block_count++;
                    break;
                case EscalatorDown1S: case EscalatorDown2S: case EscalatorDown3S: case EscalatorDown4S:
                    permanent->dynamic_blocks[used_dynamic_block_count].is_floor = 1;
                    add_dynamic_block(x_, y_, z, permanent, &used_dynamic_block_count, texture_atlas_data[block], BL_escalator_south_up_000, BL_escalator_south_up_007, 0.5f/8, 0);
                    used_dynamic_block_count++;
                    break;
                case Grass:
                case Wood:
                case Concrete:
                case Nothing:
                case Tiles:
                case Carpet:
                case EscalatorUpMeta:
                case EscalatorDownMeta:
                case StairsMeta:
                case StairsFollowUpMeta:
                case Shaded:
                case BlockTotal:

                default:
                    break;
                }
            }
        }
    }

    permanent->static_block_count      = used_static_block_count;
    permanent->dynamic_block_count     = used_dynamic_block_count;
    permanent->transparent_block_count = used_transparent_block_count;

    set_static_block_batch_sizes(permanent, renderer);
    set_dynamic_block_batch_sizes(permanent, renderer);
    set_transparent_block_batch_sizes(permanent, renderer);

    qsort(permanent->static_blocks, used_static_block_count, sizeof(StaticBlock), sort_static_blocks_front_back);
    qsort(permanent->transparent_blocks, used_transparent_block_count, sizeof(StaticBlock), sort_static_blocks_back_front);

    renderer->needs_prepare = 1;

    set_actor_batch_sizes(permanent, renderer);

    permanent->grid = PUSH_STRUCT(&permanent->arena, Grid);
    init_grid(permanent->grid, &permanent->arena, &permanent->level);
    preprocess_grid(permanent->grid);
    set_colored_line_batch_sizes(permanent, renderer);
    memory->is_initialized = true;

}
Ejemplo n.º 3
0
void handle_sequence(char c) { PUSH_ARRAY(sequence, c); }