From a4f631336e4f8816d4a58edd2c962cccee94c3a6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 11 Aug 2008 13:07:43 +0100 Subject: Subdivision fixes --- src/model.c | 2 +- src/physics.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/model.c b/src/model.c index f98d4bc..8abbc42 100644 --- a/src/model.c +++ b/src/model.c @@ -326,7 +326,7 @@ static int model_load(ModelContext *ctx, const char *name, RenderContext *render /* Subdivide the previous face if requested */ if ( !coll && subdiv && (sscanf(line, "subdivide %f %f", &x, &y) == 2) ) { if ( type == PRIMITIVE_QUADS ) { - if ( (num_vertices % 4)==0 ) { + if ( (num_vertices > 0) && ((num_vertices % 4)==0) ) { GLfloat u, v; GLfloat v1x, v1y, v1z; GLfloat v2x, v2y, v2z; diff --git a/src/physics.c b/src/physics.c index 7b6b2b7..08295a9 100644 --- a/src/physics.c +++ b/src/physics.c @@ -238,8 +238,10 @@ static int physics_collision_room(ModelInstance *obj, Game *game, double dt, Col if ( room != NULL ) { int j; for ( j=0; jnum_objects; j++ ) { - if ( physics_check_collide(obj, room->objects[j], dt, coll, room, game) ) { - found = 1; + if ( room->objects[j] != NULL ) { + if ( physics_check_collide(obj, room->objects[j], dt, coll, room, game) ) { + found = 1; + } } } } -- cgit v1.2.3