]> git.lizzy.rs Git - shadowclad.git/commitdiff
Rename Asset3D to Solid
authoroutfrost <kotlet.bahn@gmail.com>
Thu, 30 Apr 2020 01:48:24 +0000 (03:48 +0200)
committeroutfrost <kotlet.bahn@gmail.com>
Thu, 30 Apr 2020 01:48:24 +0000 (03:48 +0200)
src/engine/asset.c
src/engine/asset.h
src/engine/render.c
src/game/level.c
src/game/level.h
src/game/player.c
src/game/player.h

index 75e96f46d9c53885fcce1d569e993971bb50ed26..1d6ddb0998432e6f2da4cfacfe390c7401ab194e 100644 (file)
@@ -13,7 +13,7 @@ static const char* replaceFileExtension(const AiString path, const char* ext);
 
 
 
-const Asset3D* importAsset(const char* path) {
+const Solid* importSolid(const char* path) {
        const AiScene* scene = importScene(path);
        if (scene == NULL) {
                return NULL;
@@ -24,11 +24,11 @@ const Asset3D* importAsset(const char* path) {
 
        // TODO Consider assets with some arrays empty, and prevent zero mallocs
        
-       Asset3D* asset = malloc(sizeof(Asset3D));
-       asset->numMeshes = numMeshes;
-       asset->meshes = malloc(numMeshes * sizeof(Mesh));
-       asset->numMaterials = numMaterials;
-       asset->materials = malloc(numMaterials * sizeof(Material));
+       Solid* solid = malloc(sizeof(Solid));
+       solid->numMeshes = numMeshes;
+       solid->meshes = malloc(numMeshes * sizeof(Mesh));
+       solid->numMaterials = numMaterials;
+       solid->materials = malloc(numMaterials * sizeof(Material));
        
        for (unsigned int meshIndex = 0; meshIndex < numMeshes; ++meshIndex) {
                const AiMesh* aiMesh = scene->mMeshes[meshIndex];
@@ -76,7 +76,7 @@ const Asset3D* importAsset(const char* path) {
                        mesh.faces[faceIndex] = face;
                }
                
-               asset->meshes[meshIndex] = mesh;
+               solid->meshes[meshIndex] = mesh;
        }
        
        GLuint* textureIds = malloc(numMaterials * sizeof(GLuint));
@@ -119,12 +119,12 @@ const Asset3D* importAsset(const char* path) {
                        }
                }
                
-               asset->materials[matIndex] = material;
+               solid->materials[matIndex] = material;
        }
        glBindTexture(GL_TEXTURE_2D, 0);
        
        aiReleaseImport(scene);
-       return asset;
+       return solid;
 }
 
 static const AiScene* importScene(const char* path) {
index 8a68ca07deb4a490ba02df3c43ffe1513233549c..042361d39b6bd2260cb12017e34c1692f576fbd7 100644 (file)
@@ -7,12 +7,12 @@
 
 #include "geometry.h"
 
-typedef struct Asset3D Asset3D;
+typedef struct Solid Solid;
 typedef struct Mesh Mesh;
 typedef struct Face Face;
 typedef struct Material Material;
 
-struct Asset3D {
+struct Solid {
        size_t numMeshes;
        Mesh* meshes;
        size_t numMaterials;
@@ -38,6 +38,6 @@ struct Material {
        GLuint textureId;
 };
 
-const Asset3D* importAsset(const char* path);
+const Solid* importSolid(const char* path);
 
 #endif
index 47ec89ca5da10ed3844d8e1e34b264e8ab340c79..68385b07919af5a40cf14e00ece7d3c5b3b57034 100644 (file)
@@ -14,7 +14,7 @@ static void moveCameraTo(const Vector3D pos);
 static void drawAxes();
 static void renderBlockGrid(const BlockGrid grid);
 static void renderCharacter(const Character* character, const Vector3D pos);
-static void drawAsset3D(const Asset3D* asset3D);
+static void drawSolid(const Solid* solid);
 
 float viewportAspectRatio = 1.0f;
 
@@ -111,7 +111,7 @@ static void renderBlockGrid(const BlockGrid grid) {
                glLoadIdentity();
                glTranslatef(0.0f, 0.0f, z * BLOCKGRID_CELL_SIZE);
                for (size_t x = 0; x < grid.width; ++x) {
-                       drawAsset3D(getBlockFromGrid(grid, x, z)->asset3D);
+                       drawSolid(getBlockFromGrid(grid, x, z)->solid);
                        glTranslatef(BLOCKGRID_CELL_SIZE, 0.0f, 0.0f);
                }
        }
@@ -121,22 +121,22 @@ static void renderBlockGrid(const BlockGrid grid) {
 static void renderCharacter(const Character* character, const Vector3D pos) {
        glMatrixMode(GL_MODELVIEW);
        glTranslatef(pos.x, pos.y, pos.z);
-       drawAsset3D(character->asset3D);
+       drawSolid(character->solid);
        glLoadIdentity();
 }
 
-static void drawAsset3D(const Asset3D* asset3D) {
-       if (asset3D == NULL) {
+static void drawSolid(const Solid* solid) {
+       if (solid == NULL) {
                return;
        }
        
        glMatrixMode(GL_MODELVIEW);
        glColor3f(0.5f, 1.0f, 0.0f);
        
-       for (size_t meshIndex = 0; meshIndex < asset3D->numMeshes; ++meshIndex) {
-               const Mesh mesh = asset3D->meshes[meshIndex];
+       for (size_t meshIndex = 0; meshIndex < solid->numMeshes; ++meshIndex) {
+               const Mesh mesh = solid->meshes[meshIndex];
                glBindTexture(GL_TEXTURE_2D,
-                             asset3D->materials[mesh.materialIndex].textureId);
+                             solid->materials[mesh.materialIndex].textureId);
                bool hasNormals = mesh.normals != NULL;
                bool hasTextureCoords = mesh.textureCoords != NULL;
                
index 048db470f7e8cc9413c663ec80ac028cfc750aaa..219b2e978c4dac3bfbab9b7f96919b562266d227 100644 (file)
@@ -7,9 +7,9 @@
 #include "player.h"
 
 static Block blockEmpty = { .type = BLOCKTYPE_SPACE,
-                            .asset3D = NULL };
+                            .solid = NULL };
 static Block blockWall01 = { .type = BLOCKTYPE_OBSTACLE,
-                             .asset3D = NULL };
+                             .solid = NULL };
 
 static Block* testBlocks[9] = { &blockWall01, &blockWall01, &blockWall01,
                                 &blockEmpty, &blockEmpty, &blockEmpty,
@@ -25,7 +25,7 @@ Vector3D playerSpawnPos = DEFAULT_PLAYER_SPAWN_POS;
 
 
 void initLevel() {
-       blockWall01.asset3D = importAsset("assets/wall01.3ds");
+       blockWall01.solid = importSolid("assets/wall01.3ds");
        
        buildLevelFromImage(readTga("assets/level01.tga"));
 }
index 89d7e2e0daeb96d85c3c9b286cf1454b9595661e..ccde120b00710f95432cd5d05d397f365b264435 100644 (file)
@@ -15,7 +15,7 @@ typedef enum {
 
 typedef struct {
        const BlockType type;
-       const Asset3D* asset3D;
+       const Solid* solid;
 } Block;
 
 typedef struct {
index 32e0076f7ce756cd0b6f336edc18f3bb396e6a35..6aafb2443f97d09dc456a285232f0eaf0cf95cab 100644 (file)
@@ -3,12 +3,12 @@
 #include "level.h"
 #include "player.h"
 
-Character playerCharacter = { .asset3D = NULL };
+Character playerCharacter = { .solid = NULL };
 
 
 
 void initPlayer() {
-       playerCharacter.asset3D = importAsset("assets/playercharacter.3ds");
+       playerCharacter.solid = importSolid("assets/playercharacter.3ds");
 }
 
 void spawnPlayer() {
index eeae33b3fdd917167843bb5cd3d3b0c6a4f80244..aeeabc4efba70beacd440a7968fb2cd5539de193 100644 (file)
@@ -6,7 +6,7 @@
 #include "engine/asset.h"
 
 typedef struct {
-       const Asset3D* asset3D;
+       const Solid* solid;
 } Character;
 
 Character playerCharacter;