feat: pl_stl.h 1.0
This commit is contained in:
parent
49e7b40b08
commit
8995fe67f8
25
pl_stl.h
25
pl_stl.h
@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
pl_stl.h
|
pl_stl.h
|
||||||
|
* no dependencies
|
||||||
|
* simple asci & binary stl parser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// library version
|
// library version (format XYYZZ)
|
||||||
#define PL_STL_VERSION "0.2.0"
|
#define PL_STL_VERSION "1.0.0"
|
||||||
#define PL_STL_VERSION_NUM 00200
|
#define PL_STL_VERSION_NUM 10000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Index of this file:
|
Index of this file:
|
||||||
// [SECTION] header mess
|
// [SECTION] header mess
|
||||||
// [SECTION] includes
|
|
||||||
// [SECTION] forward declarations & basic types
|
// [SECTION] forward declarations & basic types
|
||||||
// [SECTION] public api
|
// [SECTION] public api
|
||||||
// [SECTION] structs
|
// [SECTION] structs
|
||||||
@ -23,12 +24,6 @@ Index of this file:
|
|||||||
#ifndef PL_STL_H
|
#ifndef PL_STL_H
|
||||||
#define PL_STL_H
|
#define PL_STL_H
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// [SECTION] includes
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] forward declarations & basic types
|
// [SECTION] forward declarations & basic types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -50,7 +45,7 @@ typedef struct _plStlInfo
|
|||||||
size_t szPositionStreamSize;
|
size_t szPositionStreamSize;
|
||||||
size_t szNormalStreamSize;
|
size_t szNormalStreamSize;
|
||||||
size_t szIndexBufferSize;
|
size_t szIndexBufferSize;
|
||||||
bool bPreloaded;
|
int iPreloaded;
|
||||||
} plStlInfo;
|
} plStlInfo;
|
||||||
|
|
||||||
#endif // PL_STL_H
|
#endif // PL_STL_H
|
||||||
@ -104,11 +99,11 @@ pl_load_stl(const char* pcData, size_t szDataSize, float* afPositionStream, floa
|
|||||||
ptInfoOut = &_tInternalInfo;
|
ptInfoOut = &_tInternalInfo;
|
||||||
|
|
||||||
bool bAsci = strncmp(pcData, "solid", 5) == 0;
|
bool bAsci = strncmp(pcData, "solid", 5) == 0;
|
||||||
size_t szFacetCount = ptInfoOut->bPreloaded ? ptInfoOut->szIndexBufferSize / 3 : 0;
|
size_t szFacetCount = ptInfoOut->iPreloaded ? ptInfoOut->szIndexBufferSize / 3 : 0;
|
||||||
size_t szCurrentCursor = 0;
|
size_t szCurrentCursor = 0;
|
||||||
size_t szVertexCount = ptInfoOut->bPreloaded ? ptInfoOut->szIndexBufferSize : 0;
|
size_t szVertexCount = ptInfoOut->iPreloaded ? ptInfoOut->szIndexBufferSize : 0;
|
||||||
|
|
||||||
if(!ptInfoOut->bPreloaded)
|
if(!ptInfoOut->iPreloaded)
|
||||||
{
|
{
|
||||||
|
|
||||||
// find number of vertices & facets
|
// find number of vertices & facets
|
||||||
@ -131,7 +126,7 @@ pl_load_stl(const char* pcData, size_t szDataSize, float* afPositionStream, floa
|
|||||||
szVertexCount = szFacetCount * 3;
|
szVertexCount = szFacetCount * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptInfoOut->bPreloaded = true;
|
ptInfoOut->iPreloaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptInfoOut->szIndexBufferSize = szFacetCount * 3;
|
ptInfoOut->szIndexBufferSize = szFacetCount * 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user