Browse Source

Merge branch 'master' of https://github.com/raysan5/raylib

raysan5 3 years ago
parent
commit
252bd22738
3 changed files with 116 additions and 2 deletions
  1. 8 2
      CHANGELOG
  2. 2 0
      src/raylib.h
  3. 106 0
      src/rmodels.c

+ 8 - 2
CHANGELOG

@@ -30,6 +30,7 @@ Detailed changes:
 [core] REVIEWED: Raspberry RPI/DRM keyboard blocking render loop (#1879) @luizpestana
 [core] REVIEWED: Raspberry RPI/DRM keyboard blocking render loop (#1879) @luizpestana
 [core] REVIEWED: Android multi-touch (#1869) by @humbe
 [core] REVIEWED: Android multi-touch (#1869) by @humbe
 [core] REVIEWED: Implemented GetGamepadName() for emscripten by @nbarkhina
 [core] REVIEWED: Implemented GetGamepadName() for emscripten by @nbarkhina
+[core] REVIEWED: HighDPI support (#1987) by @ArnaudValensi
 [rlgl] ADDED: rlUpdateVertexBufferElements() (#1915)
 [rlgl] ADDED: rlUpdateVertexBufferElements() (#1915)
 [rlgl] ADDED: rlActiveDrawBuffers() (#1911)
 [rlgl] ADDED: rlActiveDrawBuffers() (#1911)
 [rlgl] ADDED: rlEnableColorBlend()/rlDisableColorBlend()
 [rlgl] ADDED: rlEnableColorBlend()/rlDisableColorBlend()
@@ -43,6 +44,7 @@ Detailed changes:
 [shapes] ADDED: RenderPolyLinesEx() (#1758) by @lambertwang
 [shapes] ADDED: RenderPolyLinesEx() (#1758) by @lambertwang
 [shapes] ADDED: DrawLineBezierCubic() (#2021) by @SAOMDVN
 [shapes] ADDED: DrawLineBezierCubic() (#2021) by @SAOMDVN
 [textures] ADDED: GetImageColor() #2024
 [textures] ADDED: GetImageColor() #2024
+[textures] REMOVED: GenImagePerlinNoise() 
 [textures] RENAMED: GetTextureData() to LoadImageFromTexture()
 [textures] RENAMED: GetTextureData() to LoadImageFromTexture()
 [textures] RENAMED: GetScreenData() to LoadImageFromScreen()
 [textures] RENAMED: GetScreenData() to LoadImageFromScreen()
 [textures] REVIEWED: ExportImage() to use SaveFileData() (#1779)
 [textures] REVIEWED: ExportImage() to use SaveFileData() (#1779)
@@ -63,6 +65,7 @@ Detailed changes:
 [models] ADDED: GetModelBoundingBox()
 [models] ADDED: GetModelBoundingBox()
 [models] ADDED: DrawBillboardPro() (#1759) by @nobytesgiven
 [models] ADDED: DrawBillboardPro() (#1759) by @nobytesgiven
 [models] ADDED: DrawCubeTextureRec() (#2001) by @tdgroot
 [models] ADDED: DrawCubeTextureRec() (#2001) by @tdgroot
+[models] ADDED: DrawCylinderEx() and DrawCylinderWiresEx() (#2049) by @Horrowind
 [models] REMOVED: DrawBillboardEx()
 [models] REMOVED: DrawBillboardEx()
 [models] RENAMED: MeshBoundingBox() to GetMeshBoundingBox()
 [models] RENAMED: MeshBoundingBox() to GetMeshBoundingBox()
 [models] RENAMED: MeshTangents() to GenMeshTangents()
 [models] RENAMED: MeshTangents() to GenMeshTangents()
@@ -87,8 +90,10 @@ Detailed changes:
 [examples] ADDED: core_basic_screen_manager
 [examples] ADDED: core_basic_screen_manager
 [examples] ADDED: core_split_screen (#1806) by @JeffM2501
 [examples] ADDED: core_split_screen (#1806) by @JeffM2501
 [examples] ADDED: core_2d_camera_smooth_pixelperfect (#1771) by @NotManyIdeasDev
 [examples] ADDED: core_2d_camera_smooth_pixelperfect (#1771) by @NotManyIdeasDev
-[examples] ADDED: shaders_shapes_outline (#1883) by @GoldenThumbs
-[examples] ADDED: models_magicavoxel_loading (#1940) by @procfxgen
+[examples] ADDED: shaders_texture_outline (#1883) by @GoldenThumbs
+[examples] ADDED: models_loading_vox (#1940) by @procfxgen
+[examples] REMOVED: models_material_pbr
+[examples] REMOVED: models_gltf_animation
 [examples] REVIEWED: core_3d_picking
 [examples] REVIEWED: core_3d_picking
 [examples] REVIEWED: core_input_mouse
 [examples] REVIEWED: core_input_mouse
 [examples] REVIEWED: core_vr_simulator, RenderTexture usage
 [examples] REVIEWED: core_vr_simulator, RenderTexture usage
@@ -114,6 +119,7 @@ Detailed changes:
 [examples] REVIEWED: raylib_opengl_interop
 [examples] REVIEWED: raylib_opengl_interop
 [examples] REVIEWED: rlgl_standalone.c
 [examples] REVIEWED: rlgl_standalone.c
 [examples] REVIEWED: Resources licenses
 [examples] REVIEWED: Resources licenses
+[examples] REVIEWED: models resources reorganization
 [build] ADDED: Zig build file (#2014) by @TommiSinivuo
 [build] ADDED: Zig build file (#2014) by @TommiSinivuo
 [build] ADDED: Android VS2019 solution (#2013) by @Kronka
 [build] ADDED: Android VS2019 solution (#2013) by @Kronka
 [build] REMOVED: VS2017 project, outdated
 [build] REMOVED: VS2017 project, outdated

+ 2 - 0
src/raylib.h

@@ -1383,7 +1383,9 @@ RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color);
 RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color);            // Draw sphere with extended parameters
 RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color);            // Draw sphere with extended parameters
 RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color);         // Draw sphere wires
 RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color);         // Draw sphere wires
 RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
 RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
+RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos
 RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
 RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
+RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos
 RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color);                                      // Draw a plane XZ
 RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color);                                      // Draw a plane XZ
 RLAPI void DrawRay(Ray ray, Color color);                                                                // Draw a ray line
 RLAPI void DrawRay(Ray ray, Color color);                                                                // Draw a ray line
 RLAPI void DrawGrid(int slices, float spacing);                                                          // Draw a grid (centered at (0, 0, 0))
 RLAPI void DrawGrid(int slices, float spacing);                                                          // Draw a grid (centered at (0, 0, 0))

+ 106 - 0
src/rmodels.c

@@ -703,6 +703,64 @@ void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float h
     rlPopMatrix();
     rlPopMatrix();
 }
 }
 
 
+// Draw a cylinder with base at startPos and top at endPos
+// NOTE: It could be also used for pyramid and cone
+void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color)
+{
+    if (sides < 3) sides = 3;
+
+    int numVertex = sides*6;
+    rlCheckRenderBatchLimit(numVertex);
+    if(sides < 3) sides = 3;
+
+    Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
+    // Construct a basis of the base and the top face:
+    Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
+    Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
+
+    float baseAngle = (2.0*PI)/sides;
+
+    rlBegin(RL_TRIANGLES);
+        rlColor4ub(color.r, color.g, color.b, color.a);
+
+        for (int i = 0; i < sides; i++) {
+            // compute the four vertices
+            float s1 = sinf(baseAngle*(i + 0))*startRadius;
+            float c1 = cosf(baseAngle*(i + 0))*startRadius;
+            Vector3 w1 = { startPos.x + s1*b1.x + c1*b2.x, startPos.y + s1*b1.y + c1*b2.y, startPos.z + s1*b1.z + c1*b2.z };
+            float s2 = sinf(baseAngle*(i + 1))*startRadius;
+            float c2 = cosf(baseAngle*(i + 1))*startRadius;
+            Vector3 w2 = { startPos.x + s2*b1.x + c2*b2.x, startPos.y + s2*b1.y + c2*b2.y, startPos.z + s2*b1.z + c2*b2.z };
+            float s3 = sinf(baseAngle*(i + 0))*endRadius;
+            float c3 = cosf(baseAngle*(i + 0))*endRadius;
+            Vector3 w3 = { endPos.x + s3*b1.x + c3*b2.x, endPos.y + s3*b1.y + c3*b2.y, endPos.z + s3*b1.z + c3*b2.z };
+            float s4 = sinf(baseAngle*(i + 1))*endRadius;
+            float c4 = cosf(baseAngle*(i + 1))*endRadius;
+            Vector3 w4 = { endPos.x + s4*b1.x + c4*b2.x, endPos.y + s4*b1.y + c4*b2.y, endPos.z + s4*b1.z + c4*b2.z };
+
+            if (startRadius > 0) {                              //
+                rlVertex3f(startPos.x, startPos.y, startPos.z); // |
+                rlVertex3f(w2.x, w2.y, w2.z);                   // T0
+                rlVertex3f(w1.x, w1.y, w1.z);                   // |
+            }                                                   //
+                                                                //          w2 x.-----------x startPos
+            rlVertex3f(w1.x, w1.y, w1.z);                       // |           |\'.  T0    /
+            rlVertex3f(w2.x, w2.y, w2.z);                       // T1          | \ '.     /
+            rlVertex3f(w3.x, w3.y, w3.z);                       // |           |T \  '.  /
+                                                                //             | 2 \ T 'x w1
+            rlVertex3f(w2.x, w2.y, w2.z);                       // |        w4 x.---\-1-|---x endPos
+            rlVertex3f(w4.x, w4.y, w4.z);                       // T2            '.  \  |T3/
+            rlVertex3f(w3.x, w3.y, w3.z);                       // |               '. \ | /
+                                                                //                   '.\|/
+            if (endRadius > 0) {                                //                     'x w3
+                rlVertex3f(endPos.x, endPos.y, endPos.z);       // |
+                rlVertex3f(w3.x, w3.y, w3.z);                   // T3
+                rlVertex3f(w4.x, w4.y, w4.z);                   // |
+            }                                                   //
+        }
+    rlEnd();
+}
+
 // Draw a wired cylinder
 // Draw a wired cylinder
 // NOTE: It could be also used for pyramid and cone
 // NOTE: It could be also used for pyramid and cone
 void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int sides, Color color)
 void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int sides, Color color)
@@ -736,6 +794,54 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
     rlPopMatrix();
     rlPopMatrix();
 }
 }
 
 
+
+// Draw a wired cylinder with base at startPos and top at endPos
+// NOTE: It could be also used for pyramid and cone
+void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color)
+{
+    if (sides < 3) sides = 3;
+
+    int numVertex = sides*6;
+    rlCheckRenderBatchLimit(numVertex);
+
+    Vector3 difference = Vector3Subtract(endPos, startPos);
+    // Construct a basis of the base and the top face:
+    Vector3 b1 = Vector3Normalize(Vector3Perpendicular(difference));
+    Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, difference));
+
+    float baseAngle = (2.0*PI)/sides;
+
+    rlBegin(RL_LINES);
+        rlColor4ub(color.r, color.g, color.b, color.a);
+
+        for (int i = 0; i < sides; i++) {
+            // compute the four vertices
+            float s1 = sinf(baseAngle*(i + 0))*startRadius;
+            float c1 = cosf(baseAngle*(i + 0))*startRadius;
+            Vector3 w1 = { startPos.x + s1*b1.x + c1*b2.x, startPos.y + s1*b1.y + c1*b2.y, startPos.z + s1*b1.z + c1*b2.z };
+            float s2 = sinf(baseAngle*(i + 1))*startRadius;
+            float c2 = cosf(baseAngle*(i + 1))*startRadius;
+            Vector3 w2 = { startPos.x + s2*b1.x + c2*b2.x, startPos.y + s2*b1.y + c2*b2.y, startPos.z + s2*b1.z + c2*b2.z };
+            float s3 = sinf(baseAngle*(i + 0))*endRadius;
+            float c3 = cosf(baseAngle*(i + 0))*endRadius;
+            Vector3 w3 = { endPos.x + s3*b1.x + c3*b2.x, endPos.y + s3*b1.y + c3*b2.y, endPos.z + s3*b1.z + c3*b2.z };
+            float s4 = sinf(baseAngle*(i + 1))*endRadius;
+            float c4 = cosf(baseAngle*(i + 1))*endRadius;
+            Vector3 w4 = { endPos.x + s4*b1.x + c4*b2.x, endPos.y + s4*b1.y + c4*b2.y, endPos.z + s4*b1.z + c4*b2.z };
+
+            rlVertex3f(w1.x, w1.y, w1.z);
+            rlVertex3f(w2.x, w2.y, w2.z);
+
+            rlVertex3f(w1.x, w1.y, w1.z);
+            rlVertex3f(w3.x, w3.y, w3.z);
+
+            rlVertex3f(w3.x, w3.y, w3.z);
+            rlVertex3f(w4.x, w4.y, w4.z);
+        }
+    rlEnd();
+}
+
+
 // Draw a plane
 // Draw a plane
 void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
 void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
 {
 {