master
Jeremy Hu 2017-01-30 00:13:30 +09:30
commit be9e73b83d
8 changed files with 24 additions and 6 deletions

View File

@ -17,6 +17,11 @@ Build
$ cd build $ cd build
$ qmake -spec macx-xcode $ qmake -spec macx-xcode
``` ```
*Generate VC Project*
```
$ cd build
$ qmake -tp vc
```
*Generate Makefile* *Generate Makefile*
``` ```
$ cd build $ cd build

View File

@ -21,12 +21,13 @@ array *arrayCreate(int nodeSize) {
} }
int arraySetLength(array *arr, int length) { int arraySetLength(array *arr, int length) {
char *newNodes;
if (length > arr->capacity) { if (length > arr->capacity) {
int newCapacity = (arr->capacity + 1) * 2; int newCapacity = (arr->capacity + 1) * 2;
if (newCapacity < length) { if (newCapacity < length) {
newCapacity = length; newCapacity = length;
} }
char *newNodes = (char *)realloc(arr->nodes, arr->nodeSize * newCapacity); newNodes = (char *)realloc(arr->nodes, arr->nodeSize * newCapacity);
if (!newNodes) { if (!newNodes) {
fprintf(stderr, "%s:Insufficient memory.\n", __FUNCTION__); fprintf(stderr, "%s:Insufficient memory.\n", __FUNCTION__);
return -1; return -1;

View File

@ -924,8 +924,11 @@ static int bmeshAddWallsBetweenQuadsToModel(bmesh *bm, vec3 *origin, quad *q1,
vec3 o2v; vec3 o2v;
matchTwoFaces(q1, q2); matchTwoFaces(q1, q2);
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
quad wall = {{q1->pt[i], q2->pt[i], quad wall;
q2->pt[(i + 1) % 4], q1->pt[(i + 1) % 4]}}; wall.pt[0] = q1->pt[i];
wall.pt[1] = q2->pt[i];
wall.pt[2] = q2->pt[(i + 1) % 4];
wall.pt[3] = q1->pt[(i + 1) % 4];
vec3Normal(&wall.pt[0], &wall.pt[1], &wall.pt[2], &normal); vec3Normal(&wall.pt[0], &wall.pt[1], &wall.pt[2], &normal);
vec3Sub(&wall.pt[0], origin, &o2v); vec3Sub(&wall.pt[0], origin, &o2v);
if (vec3DotProduct(&o2v, &normal) < 0) { if (vec3DotProduct(&o2v, &normal) < 0) {

View File

@ -118,7 +118,7 @@ int drawPrintf(int x, int y, const char *fmt, ...) {
return drawText(x, y, text); return drawText(x, y, text);
} }
static const float drawDebugColors[][4] { static const float drawDebugColors[][4] = {
{1.00, 0.00, 1.00, 1.0}, {1.00, 0.00, 1.00, 1.0},
{0.00, 1.00, 1.00, 1.0}, {0.00, 1.00, 1.00, 1.0},
{1.00, 1.00, 0.00, 1.0}, {1.00, 1.00, 0.00, 1.0},

View File

@ -3,7 +3,8 @@
#include "3dstruct.h" #include "3dstruct.h"
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#else #elif defined(_WIN32)
#include <windows.h>
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif

View File

@ -2,6 +2,10 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#ifndef M_PI
#define M_PI 3.1415926
#endif
#define DEG2RAD (M_PI / 180.0) #define DEG2RAD (M_PI / 180.0)
matrix *matrixLoadIdentity(matrix *mat) { matrix *matrixLoadIdentity(matrix *mat) {

View File

@ -9,7 +9,7 @@
#include "vector3d.h" #include "vector3d.h"
#include "subdivide.h" #include "subdivide.h"
static const float bmeshBallColors[][4] { static const float bmeshBallColors[][4] = {
{0.00, 0.78, 1.00, 0.5}, {0.00, 0.78, 1.00, 0.5},
{1.00, 0.00, 0.00, 0.5}, {1.00, 0.00, 0.00, 0.5},
{1.00, 1.00, 1.00, 0.5} {1.00, 1.00, 1.00, 0.5}

View File

@ -2,6 +2,10 @@
#include "vector3d.h" #include "vector3d.h"
#include "matrix.h" #include "matrix.h"
#ifndef M_PI
#define M_PI 3.1415926
#endif
float vec3Length(vec3 *p) { float vec3Length(vec3 *p) {
double mag; double mag;
mag = p->x * p->x + p->y * p->y + p->z * p->z; mag = p->x * p->x + p->y * p->y + p->z * p->z;