17.1 C
New York
Tuesday, April 29, 2025

2D – Displacement calculation of non -valid pixels?


I’m at present utilizing a SDL_Texture *texture Like a chunk in my world that’s being injected to make floor.

Utilizing a 2D matrix of those on the aircraft. However in the course of the dynamic items of items, I first launch the textures that aren’t seen, then change the feel within the matrix (in some unspecified time in the future the complete 2D matrix strikes down or up) after which generates enhancing the feel the place I’ve to characterize New items.

static void editTexture(SDL_Texture *texture, int32_t scrn_x,
                        int32_t scrn_y, time_t seed, float freq) {
    uint8_t r = 0, g = 0, b = 0;
    unsigned char *pixels;
    int32_t pitch = 0, offset = 0, grid_x = 0, grid_y = 0;
    uint32_t colour = 0;

    SDL_LockTexture(texture, NULL, (void **)&pixels, &pitch);
    for (int y = 0; y y -= CHUNK_SIZE;
        for (int32_t i = 0; i = 0; y--) {
            for (int32_t x = 0; x y,
                                                 seed, PERLIN_TERRAIN_FREQ); }
        }
    } else if (HAS_FLAG(update_flags, DOWN)) {
        // TODO
    }
    if (HAS_FLAG(update_flags, RIGHT)) {
        // TODO
    } else if (HAS_FLAG(update_flags, LEFT)) {
        // TODO
    }
}

Within the edittexture operate, the displacement calculation shouldn’t be tied for some motive once I start to maneuver ahead.

Offset out of bounds: 828
INFO: Error: Offset out of bounds: 832
INFO: Error: Offset out of bounds: 836
INFO: Error: Offset out of bounds: 840
INFO: Error: Offset out of bounds: 844
INFO: Error: Offset out of bounds: 848
INFO: Error: Offset out of bounds: 852
INFO: Error: Offset out of bounds: 856
INFO: Error: Offset out of bounds: 860
INFO: Error: Offset out of bounds: 864
INFO: Error: Offset out of bounds: 868
INFO: Error: Offset out of bounds: 872
INFO: Error: Offset out of bounds: 876
INFO: Error: Offset out of bounds: 880
INFO: Error: Offset out of bounds: 884
INFO: Error: Offset out of bounds: 888
INFO: Error: Offset out of bounds: 892
INFO: Error: Offset out of bounds: 896
INFO: Error: Offset out of bounds: 900
INFO: Error: Offset out of bounds: 904
INFO: Error: Offset out of bounds: 908
INFO: Error: Offset out of bounds: 912
INFO: Error: Offset out of bounds: 916
INFO: Error: Offset out of bounds: 920
INFO: Error: Offset out of bounds: 924
INFO: Error: Offset out of bounds: 928
INFO: Error: Offset out of bounds: 932
INFO: Error: Offset out of bounds: 936
INFO: Error: Offset out of bounds: 940
INFO: Error: Offset out of bounds: 944
INFO: Error: Offset out of bounds: 948
INFO: Error: Offset out of bounds: 952
INFO: Error: Offset out of bounds: 956
INFO: Error: Offset out of bounds: 960
INFO: Error: Offset out of bounds: 964
INFO: Error: Offset out of bounds: 968
INFO: Error: Offset out of bounds: 972
INFO: Error: Offset out of bounds: 976
INFO: Error: Offset out of bounds: 980
INFO: Error: Offset out of bounds: 984
INFO: Error: Offset out of bounds: 988
INFO: Error: Offset out of bounds: 992
INFO: Error: Offset out of bounds: 996
INFO: Error: Offset out of bounds: 1000
INFO: Error: Offset out of bounds: 1004
INFO: Error: Offset out of bounds: 1008
INFO: Error: Offset out of bounds: 1012
INFO: Error: Offset out of bounds: 1016
INFO: Error: Offset out of bounds: 1020
INFO: Error: Offset out of bounds: 1024
INFO: Error: Offset out of bounds: 1028
INFO: Error: Offset out of bounds: 1032
INFO: Error: Offset out of bounds: 1036
INFO: Error: Offset out of bounds: 1040
INFO: Error: Offset out of bounds: 1044
INFO: Error: Offset out of bounds: 1048
INFO: Error: Offset out of bounds: 1052
INFO: Error: Offset out of bounds: 1056
INFO: Error: Offset out of bounds: 1060
INFO: Error: Offset out of bounds: 1064
INFO: Error: Offset out of bounds: 1068
INFO: Error: Offset out of bounds: 1072
INFO: Error: Offset out of bounds: 1076
INFO: Error: Offset out of bounds: 1080
INFO: Error: Offset out of bounds: 1084
INFO: Error: Offset out of bounds: 1088
INFO: Error: Offset out of bounds: 1092
INFO: Error: Offset out of bounds: 1096
INFO: Error: Offset out of bounds: 1100
INFO: Error: Offset out of bounds: 1104
INFO: Error: Offset out of bounds: 1108
INFO: Error: Offset out of bounds: 1112
INFO: Error: Offset out of bounds: 1116
INFO: Error: Offset out of bounds: 1120
INFO: Error: Offset out of bounds: 1124
INFO: Error: Offset out of bounds: 1128
INFO: Error: Offset out of bounds: 1132
INFO: Error: Offset out of bounds: 1136
INFO: Error: Offset out of bounds: 1140
INFO: Error: Offset out of bounds: 1144
INFO: Error: Offset out of bounds: 1148
INFO: Error: Offset out of bounds: 1152
INFO: Error: Offset out of bounds: 1156
INFO: Error: Offset out of bounds: 1160
INFO: Error: Offset out of bounds: 1164
INFO: Error: Offset out of bounds: 1168
INFO: Error: Offset out of bounds: 1172
INFO: Error: Offset out of bounds: 1176
INFO: Error: Offset out of bounds: 1180
INFO: Error: Offset out of bounds: 1184
INFO: Error: Offset out of bounds: 1188
INFO: Error: Offset out of bounds: 1192
INFO: Error: Offset out of bounds: 1196
INFO: Error: Offset out of bounds: 1200
INFO: Error: Offset out of bounds: 1204
INFO: Error: Offset out of bounds: 1208
INFO: Error: Offset out of bounds: 1212
INFO: Error: Offset out of bounds: 1216
INFO: Error: Offset out of bounds: 1220
INFO: Error: Offset out of bounds: 1224
INFO: Error: Offset out of bounds: 1228
INFO: Error: Offset out of bounds: 1232
INFO: Error: Offset out of bounds: 1236
INFO: Error: Offset out of bounds: 1240
INFO: Error: Offset out of bounds: 1244
INFO: Error: Offset out of bounds: 1248
INFO: Error: Offset out of bounds: 1252
INFO: Error: Offset out of bounds: 1256
INFO: Error: Offset out of bounds: 1260
INFO: Error: Offset out of bounds: 1264
INFO: Error: Offset out of bounds: 1268
INFO: Error: Offset out of bounds: 1272
INFO: Error: Offset out of bounds: 1276
INFO: Error: Offset out of bounds: 1280
INFO: Error: Offset out of bounds: 1284
INFO: Error: Offset out of bounds: 1288
INFO: Error: Offset out of bounds: 1292
INFO: Error: Offset out of bounds: 1296
INFO: Error: Offset out of bounds: 1300
INFO: Error: Offset out of bounds: 1304
INFO: Error: Offset out of bounds: 1308
INFO: Error: Offset out of bounds: 1312
INFO: Error: Offset out of bounds: 1316
INFO: Error: Offset out of bounds: 1320
INFO: Error: Offset out of bounds: 1324
INFO: Error: Offset out of bounds: 1328
INFO: Error: Offset out of bounds: 1332
INFO: Error: Offset out of bounds: 1336
INFO: Error: Offset out of bounds: 1340
INFO: Error: Offset out of bounds: 1344
INFO: Error: Offset out of bounds: 1348
INFO: Error: Offset out of bounds: 1352
INFO: Error: Offset out of bounds: 1356
INFO: Error: Offset out of bounds: 1360
INFO: Error: Offset out of bounds: 1364
INFO: Error: Offset out of bounds: 1368
INFO: Error: Offset out of bounds: 1372
INFO: Error: Offset out of bounds: 1376
INFO: Error: Offset out of bounds: 1380
INFO: Error: Offset out of bounds: 1384

That is the error document, the error begins from 0 after which 4 after which 8 to 1996.

I used TILE_SIZE = 1, CHUNK_SIZE = 500 For this race.

As well as, the creation, the change of components within the matrix and the version is an inefficient course of, since when it edits the feel whereas the FPS strikes to roughly 3.

Is there any approach to enhance this, that’s, another technique that works higher for my use case?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles