diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-17 13:58:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-17 13:58:26 +0400 |
commit | f5f25b81e8963aeba0a4c09f09358de070e0f927 (patch) | |
tree | c7fd6345d3a372845a0621e90087f88c90e4b8b8 | |
parent | 245c94a75e60c2c0b58c1f39d189258e2e424e29 (diff) |
style cleanup:
also fix for building ghost test and fix double free in one of the tests
66 files changed, 2063 insertions, 2059 deletions
diff --git a/extern/recastnavigation/recast-capi.cpp b/extern/recastnavigation/recast-capi.cpp index 9aeb0d65cb0..1cf8ed5546e 100644 --- a/extern/recastnavigation/recast-capi.cpp +++ b/extern/recastnavigation/recast-capi.cpp @@ -278,7 +278,7 @@ static inline void swapfunc(char *, char *, int, int); #define min(a, b) (a) < (b) ? a : b #define swapcode(TYPE, parmi, parmj, n) \ { \ - long i = (n) / sizeof (TYPE); \ + long i = (n) / sizeof(TYPE); \ TYPE *pi = (TYPE *) (parmi); \ TYPE *pj = (TYPE *) (parmj); \ do { \ diff --git a/intern/bsp/test/BSP_GhostTest/plyfile.c b/intern/bsp/test/BSP_GhostTest/plyfile.c index 9cb9d81da22..b0134f06557 100644 --- a/intern/bsp/test/BSP_GhostTest/plyfile.c +++ b/intern/bsp/test/BSP_GhostTest/plyfile.c @@ -28,37 +28,37 @@ /* -The interface routines for reading and writing PLY polygon files. + The interface routines for reading and writing PLY polygon files. -Greg Turk, February 1994 + Greg Turk, February 1994 ---------------------------------------------------------------- + --------------------------------------------------------------- -A PLY file contains a single polygonal _object_. + A PLY file contains a single polygonal _object_. -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. + An object is composed of lists of _elements_. Typical elements are + vertices, faces, edges and materials. -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties the floating-point values x,y,z and the three unsigned -chars representing red, green and blue. + Each type of element for a given object has one or more _properties_ + associated with the element type. For instance, a vertex element may + have as properties the floating-point values x,y,z and the three unsigned + chars representing red, green and blue. ---------------------------------------------------------------- + --------------------------------------------------------------- -Copyright (c) 1994 The Board of Trustees of The Leland Stanford -Junior University. All rights reserved. + Copyright (c) 1994 The Board of Trustees of The Leland Stanford + Junior University. All rights reserved. -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. + Permission to use, copy, modify and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that the above copyright notice and this permission notice appear in + all copies of this software and that you do not sell the software. -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -*/ + */ #include <stdio.h> #include <stdlib.h> @@ -67,14 +67,14 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. #include "ply.h" char *type_names[] = { -"invalid", -"char", "short", "int", -"uchar", "ushort", "uint", -"float", "double", + "invalid", + "char", "short", "int", + "uchar", "ushort", "uint", + "float", "double", }; int ply_type_size[] = { - 0, 1, 2, 4, 1, 2, 4, 4, 8 + 0, 1, 2, 4, 1, 2, 4, 4, 8 }; #define NO_OTHER_PROPS -1 @@ -96,7 +96,7 @@ PlyElement *find_element(PlyFile *, char *); PlyProperty *find_property(PlyElement *, char *, int *); /* write to a file the word describing a PLY file data type */ -void write_scalar_type (FILE *, int); +void write_scalar_type(FILE *, int); /* read a line from a file and break it up into separate words */ char **get_words(FILE *, int *, char **); @@ -120,7 +120,7 @@ void copy_property(PlyProperty *, PlyProperty *); void store_item(char *, int, int, unsigned int, double); /* return the value of a stored item */ -void get_stored_item( void *, int, int *, unsigned int *, double *); +void get_stored_item(void *, int, int *, unsigned int *, double *); /* return the value stored in an item, given ptr to it and its type */ double get_item_value(char *, int); @@ -143,551 +143,551 @@ char *my_alloc(int, int, char *); /****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. + Given a file pointer, get ready to write PLY data to the file. -Entry: - fp - the given file pointer - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary + Entry: + fp - the given file pointer + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary -Exit: - returns a pointer to a PlyFile, used to refer to this file, or NULL if error + Exit: + returns a pointer to a PlyFile, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_write( - FILE *fp, - int nelems, - char **elem_names, - int file_type -) + FILE *fp, + int nelems, + char **elem_names, + int file_type + ) { - int i; - PlyFile *plyfile; - PlyElement *elem; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - /* create a record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - plyfile->file_type = file_type; - plyfile->num_comments = 0; - plyfile->num_obj_info = 0; - plyfile->nelems = nelems; - plyfile->version = 1.0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* tuck aside the names of the elements */ - - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *) * nelems); - for (i = 0; i < nelems; i++) { - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - plyfile->elems[i] = elem; - elem->name = strdup (elem_names[i]); - elem->num = 0; - elem->nprops = 0; - } - - /* return pointer to the file descriptor */ - return (plyfile); + int i; + PlyFile *plyfile; + PlyElement *elem; + + /* check for NULL file pointer */ + if (fp == NULL) + return (NULL); + + /* create a record for this object */ + + plyfile = (PlyFile *) myalloc(sizeof(PlyFile)); + plyfile->file_type = file_type; + plyfile->num_comments = 0; + plyfile->num_obj_info = 0; + plyfile->nelems = nelems; + plyfile->version = 1.0; + plyfile->fp = fp; + plyfile->other_elems = NULL; + + /* tuck aside the names of the elements */ + + plyfile->elems = (PlyElement **) myalloc(sizeof(PlyElement *) * nelems); + for (i = 0; i < nelems; i++) { + elem = (PlyElement *) myalloc(sizeof(PlyElement)); + plyfile->elems[i] = elem; + elem->name = strdup(elem_names[i]); + elem->num = 0; + elem->nprops = 0; + } + + /* return pointer to the file descriptor */ + return (plyfile); } /****************************************************************************** -Open a polygon file for writing. + Open a polygon file for writing. -Entry: - filename - name of file to read from - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary + Entry: + filename - name of file to read from + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary -Exit: - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error + Exit: + version - version number of PLY file + returns a file identifier, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_open_for_writing( - char *filename, - int nelems, - char **elem_names, - int file_type, - float *version -) + char *filename, + int nelems, + char **elem_names, + int file_type, + float *version + ) { - PlyFile *plyfile; - char *name; - FILE *fp; + PlyFile *plyfile; + char *name; + FILE *fp; - /* tack on the extension .ply, if necessary */ + /* tack on the extension .ply, if necessary */ - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); + name = (char *) myalloc(sizeof(char) * (strlen(filename) + 5)); + strcpy(name, filename); + if (strlen(name) < 4 || + strcmp(name + strlen(name) - 4, ".ply") != 0) + strcat(name, ".ply"); - /* open the file for writing */ + /* open the file for writing */ - fp = fopen (name, "w"); - if (fp == NULL) { - return (NULL); - } + fp = fopen(name, "w"); + if (fp == NULL) { + return (NULL); + } - /* create the actual PlyFile structure */ + /* create the actual PlyFile structure */ - plyfile = ply_write (fp, nelems, elem_names, file_type); - if (plyfile == NULL) - return (NULL); + plyfile = ply_write(fp, nelems, elem_names, file_type); + if (plyfile == NULL) + return (NULL); - /* say what PLY file version number we're writing */ - *version = plyfile->version; + /* say what PLY file version number we're writing */ + *version = plyfile->version; - /* return pointer to the file descriptor */ - return (plyfile); + /* return pointer to the file descriptor */ + return (plyfile); } /****************************************************************************** -Describe an element, including its properties and how many will be written -to the file. - -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written - nprops - number of properties contained in the element - prop_list - list of properties + Describe an element, including its properties and how many will be written + to the file. + + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + nelems - number of elements of this type to be written + nprops - number of properties contained in the element + prop_list - list of properties ******************************************************************************/ void ply_describe_element( - PlyFile *plyfile, - char *elem_name, - int nelems, - int nprops, - PlyProperty *prop_list -) + PlyFile *plyfile, + char *elem_name, + int nelems, + int nprops, + PlyProperty *prop_list + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_describe_element: can't find element '%s'\n",elem_name); - exit (-1); - } - - elem->num = nelems; - - /* copy the list of properties */ - - elem->nprops = nprops; - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *) * nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * nprops); - - for (i = 0; i < nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[i] = prop; - elem->store_prop[i] = NAMED_PROP; - copy_property (prop, &prop_list[i]); - } + int i; + PlyElement *elem; + PlyProperty *prop; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_element: can't find element '%s'\n", elem_name); + exit(-1); + } + + elem->num = nelems; + + /* copy the list of properties */ + + elem->nprops = nprops; + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *) * nprops); + elem->store_prop = (char *) myalloc(sizeof(char) * nprops); + + for (i = 0; i < nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + elem->props[i] = prop; + elem->store_prop[i] = NAMED_PROP; + copy_property(prop, &prop_list[i]); + } } /****************************************************************************** -Describe a property of an element. + Describe a property of an element. -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - prop - the new property + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + prop - the new property ******************************************************************************/ void ply_describe_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop -) + PlyFile *plyfile, + char *elem_name, + PlyProperty *prop + ) { - PlyElement *elem; - PlyProperty *elem_prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_property: can't find element '%s'\n", - elem_name); - return; - } - - /* create room for new property */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - elem->store_prop = (char *) myalloc (sizeof (char)); - elem->nprops = 1; - } - else { - elem->nprops++; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * elem->nprops); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * elem->nprops); - } - - /* copy the new property */ - - elem_prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property (elem_prop, prop); + PlyElement *elem; + PlyProperty *elem_prop; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_property: can't find element '%s'\n", + elem_name); + return; + } + + /* create room for new property */ + + if (elem->nprops == 0) { + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *)); + elem->store_prop = (char *) myalloc(sizeof(char)); + elem->nprops = 1; + } + else { + elem->nprops++; + elem->props = (PlyProperty **) + realloc(elem->props, sizeof(PlyProperty *) * elem->nprops); + elem->store_prop = (char *) + realloc(elem->store_prop, sizeof(char) * elem->nprops); + } + + /* copy the new property */ + + elem_prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + elem->props[elem->nprops - 1] = elem_prop; + elem->store_prop[elem->nprops - 1] = NAMED_PROP; + copy_property(elem_prop, prop); } /****************************************************************************** -Describe what the "other" properties are that are to be stored, and where -they are in an element. + Describe what the "other" properties are that are to be stored, and where + they are in an element. ******************************************************************************/ void ply_describe_other_properties( - PlyFile *plyfile, - PlyOtherProp *other, - int offset -) + PlyFile *plyfile, + PlyOtherProp *other, + int offset + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, other->name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_other_properties: can't find element '%s'\n", - other->name); - return; - } - - /* create room for other properties */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) - myalloc (sizeof (PlyProperty *) * other->nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * other->nprops); - elem->nprops = 0; - } - else { - int newsize; - newsize = elem->nprops + other->nprops; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * newsize); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * newsize); - } - - /* copy the other properties */ - - for (i = 0; i < other->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, other->props[i]); - elem->props[elem->nprops] = prop; - elem->store_prop[elem->nprops] = OTHER_PROP; - elem->nprops++; - } - - /* save other info about other properties */ - elem->other_size = other->size; - elem->other_offset = offset; + int i; + PlyElement *elem; + PlyProperty *prop; + + /* look for appropriate element */ + elem = find_element(plyfile, other->name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_other_properties: can't find element '%s'\n", + other->name); + return; + } + + /* create room for other properties */ + + if (elem->nprops == 0) { + elem->props = (PlyProperty **) + myalloc(sizeof(PlyProperty *) * other->nprops); + elem->store_prop = (char *) myalloc(sizeof(char) * other->nprops); + elem->nprops = 0; + } + else { + int newsize; + newsize = elem->nprops + other->nprops; + elem->props = (PlyProperty **) + realloc(elem->props, sizeof(PlyProperty *) * newsize); + elem->store_prop = (char *) + realloc(elem->store_prop, sizeof(char) * newsize); + } + + /* copy the other properties */ + + for (i = 0; i < other->nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, other->props[i]); + elem->props[elem->nprops] = prop; + elem->store_prop[elem->nprops] = OTHER_PROP; + elem->nprops++; + } + + /* save other info about other properties */ + elem->other_size = other->size; + elem->other_offset = offset; } /****************************************************************************** -State how many of a given element will be written. + State how many of a given element will be written. -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + nelems - number of elements of this type to be written ******************************************************************************/ void ply_element_count( - PlyFile *plyfile, - char *elem_name, - int nelems -) + PlyFile *plyfile, + char *elem_name, + int nelems + ) { - PlyElement *elem; + PlyElement *elem; - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_element_count: can't find element '%s'\n",elem_name); - exit (-1); - } + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_element_count: can't find element '%s'\n", elem_name); + exit(-1); + } - elem->num = nelems; + elem->num = nelems; } /****************************************************************************** -Signal that we've described everything a PLY file's header and that the -header should be written to the file. + Signal that we've described everything a PLY file's header and that the + header should be written to the file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier ******************************************************************************/ void ply_header_complete(PlyFile *plyfile) { - int i,j; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - - fprintf (fp, "ply\n"); - - switch (plyfile->file_type) { - case PLY_ASCII: - fprintf (fp, "format ascii 1.0\n"); - break; - case PLY_BINARY_BE: - fprintf (fp, "format binary_big_endian 1.0\n"); - break; - case PLY_BINARY_LE: - fprintf (fp, "format binary_little_endian 1.0\n"); - break; - default: - fprintf (stderr, "ply_header_complete: bad file type = %d\n", - plyfile->file_type); - exit (-1); - } - - /* write out the comments */ - - for (i = 0; i < plyfile->num_comments; i++) - fprintf (fp, "comment %s\n", plyfile->comments[i]); - - /* write out object information */ - - for (i = 0; i < plyfile->num_obj_info; i++) - fprintf (fp, "obj_info %s\n", plyfile->obj_info[i]); - - /* write out information about each element */ - - for (i = 0; i < plyfile->nelems; i++) { - - elem = plyfile->elems[i]; - fprintf (fp, "element %s %d\n", elem->name, elem->num); - - /* write out each property */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (prop->is_list) { - fprintf (fp, "property list "); - write_scalar_type (fp, prop->count_external); - fprintf (fp, " "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - else { - fprintf (fp, "property "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - } - } - - fprintf (fp, "end_header\n"); + int i, j; + FILE *fp = plyfile->fp; + PlyElement *elem; + PlyProperty *prop; + + fprintf(fp, "ply\n"); + + switch (plyfile->file_type) { + case PLY_ASCII: + fprintf(fp, "format ascii 1.0\n"); + break; + case PLY_BINARY_BE: + fprintf(fp, "format binary_big_endian 1.0\n"); + break; + case PLY_BINARY_LE: + fprintf(fp, "format binary_little_endian 1.0\n"); + break; + default: + fprintf(stderr, "ply_header_complete: bad file type = %d\n", + plyfile->file_type); + exit(-1); + } + + /* write out the comments */ + + for (i = 0; i < plyfile->num_comments; i++) + fprintf(fp, "comment %s\n", plyfile->comments[i]); + + /* write out object information */ + + for (i = 0; i < plyfile->num_obj_info; i++) + fprintf(fp, "obj_info %s\n", plyfile->obj_info[i]); + + /* write out information about each element */ + + for (i = 0; i < plyfile->nelems; i++) { + + elem = plyfile->elems[i]; + fprintf(fp, "element %s %d\n", elem->name, elem->num); + + /* write out each property */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (prop->is_list) { + fprintf(fp, "property list "); + write_scalar_type(fp, prop->count_external); + fprintf(fp, " "); + write_scalar_type(fp, prop->external_type); + fprintf(fp, " %s\n", prop->name); + } + else { + fprintf(fp, "property "); + write_scalar_type(fp, prop->external_type); + fprintf(fp, " %s\n", prop->name); + } + } + } + + fprintf(fp, "end_header\n"); } /****************************************************************************** -Specify which elements are going to be written. This should be called -before a call to the routine ply_put_element(). + Specify which elements are going to be written. This should be called + before a call to the routine ply_put_element(). -Entry: - plyfile - file identifier - elem_name - name of element we're talking about + Entry: + plyfile - file identifier + elem_name - name of element we're talking about ******************************************************************************/ void ply_put_element_setup(PlyFile *plyfile, char *elem_name) { - PlyElement *elem; + PlyElement *elem; - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name); - exit (-1); - } + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name); + exit(-1); + } - plyfile->which_elem = elem; + plyfile->which_elem = elem; } /****************************************************************************** -Write an element to the file. This routine assumes that we're -writing the type of element specified in the last call to the routine -ply_put_element_setup(). + Write an element to the file. This routine assumes that we're + writing the type of element specified in the last call to the routine + ply_put_element_setup(). -Entry: - plyfile - file identifier - elem_ptr - pointer to the element + Entry: + plyfile - file identifier + elem_ptr - pointer to the element ******************************************************************************/ void ply_put_element(PlyFile *plyfile, void *elem_ptr) { - int j,k; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - char *elem_data,*item; - char **item_ptr; - int list_count; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - char **other_ptr; - - elem = plyfile->which_elem; - elem_data = elem_ptr; - other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset); - - /* write out either to an ascii or binary file */ - - if (plyfile->file_type == PLY_ASCII) { - - /* write an ascii file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - } - } - - fprintf (fp, "\n"); - } - else { - - /* write a binary file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - item_size = ply_type_size[prop->count_internal]; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - item_size = ply_type_size[prop->internal_type]; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->external_type); - } - } - - } + int j, k; + FILE *fp = plyfile->fp; + PlyElement *elem; + PlyProperty *prop; + char *elem_data, *item; + char **item_ptr; + int list_count; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + char **other_ptr; + + elem = plyfile->which_elem; + elem_data = elem_ptr; + other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset); + + /* write out either to an ascii or binary file */ + + if (plyfile->file_type == PLY_ASCII) { + + /* write an ascii file */ + + /* write out each property of the element */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (elem->store_prop[j] == OTHER_PROP) + elem_data = *other_ptr; + else + elem_data = elem_ptr; + if (prop->is_list) { + item = elem_data + prop->count_offset; + get_stored_item((void *) item, prop->count_internal, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->count_external); + list_count = uint_val; + item_ptr = (char **) (elem_data + prop->offset); + item = item_ptr[0]; + item_size = ply_type_size[prop->internal_type]; + for (k = 0; k < list_count; k++) { + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->external_type); + item += item_size; + } + } + else { + item = elem_data + prop->offset; + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->external_type); + } + } + + fprintf(fp, "\n"); + } + else { + + /* write a binary file */ + + /* write out each property of the element */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (elem->store_prop[j] == OTHER_PROP) + elem_data = *other_ptr; + else + elem_data = elem_ptr; + if (prop->is_list) { + item = elem_data + prop->count_offset; + item_size = ply_type_size[prop->count_internal]; + get_stored_item((void *) item, prop->count_internal, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->count_external); + list_count = uint_val; + item_ptr = (char **) (elem_data + prop->offset); + item = item_ptr[0]; + item_size = ply_type_size[prop->internal_type]; + for (k = 0; k < list_count; k++) { + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->external_type); + item += item_size; + } + } + else { + item = elem_data + prop->offset; + item_size = ply_type_size[prop->internal_type]; + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->external_type); + } + } + + } } /****************************************************************************** -Specify a comment that will be written in the header. + Specify a comment that will be written in the header. -Entry: - plyfile - file identifier - comment - the comment to be written + Entry: + plyfile - file identifier + comment - the comment to be written ******************************************************************************/ void ply_put_comment(PlyFile *plyfile, char *comment) { - /* (re)allocate space for new comment */ - if (plyfile->num_comments == 0) - plyfile->comments = (char **) myalloc (sizeof (char *)); - else - plyfile->comments = (char **) realloc (plyfile->comments, - sizeof (char *) * (plyfile->num_comments + 1)); - - /* add comment to list */ - plyfile->comments[plyfile->num_comments] = strdup (comment); - plyfile->num_comments++; + /* (re)allocate space for new comment */ + if (plyfile->num_comments == 0) + plyfile->comments = (char **) myalloc(sizeof(char *)); + else + plyfile->comments = (char **) realloc(plyfile->comments, + sizeof(char *) * (plyfile->num_comments + 1)); + + /* add comment to list */ + plyfile->comments[plyfile->num_comments] = strdup(comment); + plyfile->num_comments++; } /****************************************************************************** -Specify a piece of object information (arbitrary text) that will be written -in the header. + Specify a piece of object information (arbitrary text) that will be written + in the header. -Entry: - plyfile - file identifier - obj_info - the text information to be written + Entry: + plyfile - file identifier + obj_info - the text information to be written ******************************************************************************/ void ply_put_obj_info(PlyFile *plyfile, char *obj_info) { - /* (re)allocate space for new info */ - if (plyfile->num_obj_info == 0) - plyfile->obj_info = (char **) myalloc (sizeof (char *)); - else - plyfile->obj_info = (char **) realloc (plyfile->obj_info, - sizeof (char *) * (plyfile->num_obj_info + 1)); - - /* add info to list */ - plyfile->obj_info[plyfile->num_obj_info] = strdup (obj_info); - plyfile->num_obj_info++; + /* (re)allocate space for new info */ + if (plyfile->num_obj_info == 0) + plyfile->obj_info = (char **) myalloc(sizeof(char *)); + else + plyfile->obj_info = (char **) realloc(plyfile->obj_info, + sizeof(char *) * (plyfile->num_obj_info + 1)); + + /* add info to list */ + plyfile->obj_info[plyfile->num_obj_info] = strdup(obj_info); + plyfile->num_obj_info++; } @@ -703,507 +703,507 @@ void ply_put_obj_info(PlyFile *plyfile, char *obj_info) /****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. + Given a file pointer, get ready to read PLY data from the file. -Entry: - fp - the given file pointer + Entry: + fp - the given file pointer -Exit: - nelems - number of elements in object - elem_names - list of element names - returns a pointer to a PlyFile, used to refer to this file, or NULL if error + Exit: + nelems - number of elements in object + elem_names - list of element names + returns a pointer to a PlyFile, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_read(FILE *fp, int *nelems, char ***elem_names) { - int i,j; - PlyFile *plyfile; - int nwords; - char **words; - int found_format = 0; - char **elist; - PlyElement *elem; - char *orig_line; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - /* create record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - plyfile->nelems = 0; - plyfile->comments = NULL; - plyfile->num_comments = 0; - plyfile->obj_info = NULL; - plyfile->num_obj_info = 0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* read and parse the file's header */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (!words || !equal_strings (words[0], "ply")) - return (NULL); - - while (words) { - - /* parse words */ - - if (equal_strings (words[0], "format")) { - if (nwords != 3) - return (NULL); - if (equal_strings (words[1], "ascii")) - plyfile->file_type = PLY_ASCII; - else if (equal_strings (words[1], "binary_big_endian")) - plyfile->file_type = PLY_BINARY_BE; - else if (equal_strings (words[1], "binary_little_endian")) - plyfile->file_type = PLY_BINARY_LE; - else - return (NULL); - plyfile->version = (float)atof (words[2]); - found_format = 1; - } - else if (equal_strings (words[0], "element")) - add_element (plyfile, words); - else if (equal_strings (words[0], "property")) - add_property (plyfile, words); - else if (equal_strings (words[0], "comment")) - add_comment (plyfile, orig_line); - else if (equal_strings (words[0], "obj_info")) - add_obj_info (plyfile, orig_line); - else if (equal_strings (words[0], "end_header")) - break; - - /* free up words space */ - free (words); - - words = get_words (plyfile->fp, &nwords, &orig_line); - } - - /* create tags for each property of each element, to be used */ - /* later to say whether or not to store each property for the user */ - - for (i = 0; i < plyfile->nelems; i++) { - elem = plyfile->elems[i]; - elem->store_prop = (char *) myalloc (sizeof (char) * elem->nprops); - for (j = 0; j < elem->nprops; j++) - elem->store_prop[j] = DONT_STORE_PROP; - elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ - } - - /* set return values about the elements */ - - elist = (char **) myalloc (sizeof (char *) * plyfile->nelems); - for (i = 0; i < plyfile->nelems; i++) - elist[i] = strdup (plyfile->elems[i]->name); - - *elem_names = elist; - *nelems = plyfile->nelems; - - /* return a pointer to the file's information */ - - return (plyfile); + int i, j; + PlyFile *plyfile; + int nwords; + char **words; + int found_format = 0; + char **elist; + PlyElement *elem; + char *orig_line; + + /* check for NULL file pointer */ + if (fp == NULL) + return (NULL); + + /* create record for this object */ + + plyfile = (PlyFile *) myalloc(sizeof(PlyFile)); + plyfile->nelems = 0; + plyfile->comments = NULL; + plyfile->num_comments = 0; + plyfile->obj_info = NULL; + plyfile->num_obj_info = 0; + plyfile->fp = fp; + plyfile->other_elems = NULL; + + /* read and parse the file's header */ + + words = get_words(plyfile->fp, &nwords, &orig_line); + if (!words || !equal_strings(words[0], "ply")) + return (NULL); + + while (words) { + + /* parse words */ + + if (equal_strings(words[0], "format")) { + if (nwords != 3) + return (NULL); + if (equal_strings(words[1], "ascii")) + plyfile->file_type = PLY_ASCII; + else if (equal_strings(words[1], "binary_big_endian")) + plyfile->file_type = PLY_BINARY_BE; + else if (equal_strings(words[1], "binary_little_endian")) + plyfile->file_type = PLY_BINARY_LE; + else + return (NULL); + plyfile->version = (float)atof(words[2]); + found_format = 1; + } + else if (equal_strings(words[0], "element")) + add_element(plyfile, words); + else if (equal_strings(words[0], "property")) + add_property(plyfile, words); + else if (equal_strings(words[0], "comment")) + add_comment(plyfile, orig_line); + else if (equal_strings(words[0], "obj_info")) + add_obj_info(plyfile, orig_line); + else if (equal_strings(words[0], "end_header")) + break; + + /* free up words space */ + free(words); + + words = get_words(plyfile->fp, &nwords, &orig_line); + } + + /* create tags for each property of each element, to be used */ + /* later to say whether or not to store each property for the user */ + + for (i = 0; i < plyfile->nelems; i++) { + elem = plyfile->elems[i]; + elem->store_prop = (char *) myalloc(sizeof(char) * elem->nprops); + for (j = 0; j < elem->nprops; j++) + elem->store_prop[j] = DONT_STORE_PROP; + elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ + } + + /* set return values about the elements */ + + elist = (char **) myalloc(sizeof(char *) * plyfile->nelems); + for (i = 0; i < plyfile->nelems; i++) + elist[i] = strdup(plyfile->elems[i]->name); + + *elem_names = elist; + *nelems = plyfile->nelems; + + /* return a pointer to the file's information */ + + return (plyfile); } /****************************************************************************** -Open a polygon file for reading. + Open a polygon file for reading. -Entry: - filename - name of file to read from + Entry: + filename - name of file to read from -Exit: - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error + Exit: + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary + version - version number of PLY file + returns a file identifier, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_open_for_reading( - char *filename, - int *nelems, - char ***elem_names, - int *file_type, - float *version -) + char *filename, + int *nelems, + char ***elem_names, + int *file_type, + float *version + ) { - FILE *fp; - PlyFile *plyfile; - char *name; + FILE *fp; + PlyFile *plyfile; + char *name; - /* tack on the extension .ply, if necessary */ + /* tack on the extension .ply, if necessary */ - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); + name = (char *) myalloc(sizeof(char) * (strlen(filename) + 5)); + strcpy(name, filename); + if (strlen(name) < 4 || + strcmp(name + strlen(name) - 4, ".ply") != 0) + strcat(name, ".ply"); - /* open the file for reading */ + /* open the file for reading */ - fp = fopen (name, "r"); - if (fp == NULL) - return (NULL); + fp = fopen(name, "r"); + if (fp == NULL) + return (NULL); - /* create the PlyFile data structure */ + /* create the PlyFile data structure */ - plyfile = ply_read (fp, nelems, elem_names); + plyfile = ply_read(fp, nelems, elem_names); - /* determine the file type and version */ + /* determine the file type and version */ - *file_type = plyfile->file_type; - *version = plyfile->version; + *file_type = plyfile->file_type; + *version = plyfile->version; - /* return a pointer to the file's information */ + /* return a pointer to the file's information */ - return (plyfile); + return (plyfile); } /****************************************************************************** -Get information about a particular element. + Get information about a particular element. -Entry: - plyfile - file identifier - elem_name - name of element to get information about + Entry: + plyfile - file identifier + elem_name - name of element to get information about -Exit: - nelems - number of elements of this type in the file - nprops - number of properties - returns a list of properties, or NULL if the file doesn't contain that elem + Exit: + nelems - number of elements of this type in the file + nprops - number of properties + returns a list of properties, or NULL if the file doesn't contain that elem ******************************************************************************/ PlyProperty **ply_get_element_description( - PlyFile *plyfile, - char *elem_name, - int *nelems, - int *nprops -) + PlyFile *plyfile, + char *elem_name, + int *nelems, + int *nprops + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - PlyProperty **prop_list; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) - return (NULL); - - *nelems = elem->num; - *nprops = elem->nprops; - - /* make a copy of the element's property list */ - prop_list = (PlyProperty **) myalloc (sizeof (PlyProperty *) * elem->nprops); - for (i = 0; i < elem->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - prop_list[i] = prop; - } - - /* return this duplicate property list */ - return (prop_list); + int i; + PlyElement *elem; + PlyProperty *prop; + PlyProperty **prop_list; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) + return (NULL); + + *nelems = elem->num; + *nprops = elem->nprops; + + /* make a copy of the element's property list */ + prop_list = (PlyProperty **) myalloc(sizeof(PlyProperty *) * elem->nprops); + for (i = 0; i < elem->nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, elem->props[i]); + prop_list[i] = prop; + } + + /* return this duplicate property list */ + return (prop_list); } /****************************************************************************** -Specify which properties of an element are to be returned. This should be -called before a call to the routine ply_get_element(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - nprops - number of properties - prop_list - list of properties + Specify which properties of an element are to be returned. This should be + called before a call to the routine ply_get_element(). + + Entry: + plyfile - file identifier + elem_name - which element we're talking about + nprops - number of properties + prop_list - list of properties ******************************************************************************/ void ply_get_element_setup( - PlyFile *plyfile, - char *elem_name, - int nprops, - PlyProperty *prop_list -) + PlyFile *plyfile, + char *elem_name, + int nprops, + PlyProperty *prop_list + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - for (i = 0; i < nprops; i++) { - - /* look for actual property */ - prop = find_property (elem, prop_list[i].name, &index); - if (prop == NULL) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop_list[i].name, elem_name); - continue; - } - - /* store its description */ - prop->internal_type = prop_list[i].internal_type; - prop->offset = prop_list[i].offset; - prop->count_internal = prop_list[i].count_internal; - prop->count_offset = prop_list[i].count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } + int i; + PlyElement *elem; + PlyProperty *prop; + int index; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + plyfile->which_elem = elem; + + /* deposit the property information into the element's description */ + for (i = 0; i < nprops; i++) { + + /* look for actual property */ + prop = find_property(elem, prop_list[i].name, &index); + if (prop == NULL) { + fprintf(stderr, "Warning: Can't find property '%s' in element '%s'\n", + prop_list[i].name, elem_name); + continue; + } + + /* store its description */ + prop->internal_type = prop_list[i].internal_type; + prop->offset = prop_list[i].offset; + prop->count_internal = prop_list[i].count_internal; + prop->count_offset = prop_list[i].count_offset; + + /* specify that the user wants this property */ + elem->store_prop[index] = STORE_PROP; + } } /****************************************************************************** -Specify a property of an element that is to be returned. This should be -called (usually multiple times) before a call to the routine ply_get_element(). -This routine should be used in preference to the less flexible old routine -called ply_get_element_setup(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - prop - property to add to those that will be returned + Specify a property of an element that is to be returned. This should be + called (usually multiple times) before a call to the routine ply_get_element(). + This routine should be used in preference to the less flexible old routine + called ply_get_element_setup(). + + Entry: + plyfile - file identifier + elem_name - which element we're talking about + prop - property to add to those that will be returned ******************************************************************************/ void ply_get_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop -) + PlyFile *plyfile, + char *elem_name, + PlyProperty *prop + ) { - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property (elem, prop->name, &index); - if (prop_ptr == NULL) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem_name); - return; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; + PlyElement *elem; + PlyProperty *prop_ptr; + int index; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + plyfile->which_elem = elem; + + /* deposit the property information into the element's description */ + + prop_ptr = find_property(elem, prop->name, &index); + if (prop_ptr == NULL) { + fprintf(stderr, "Warning: Can't find property '%s' in element '%s'\n", + prop->name, elem_name); + return; + } + prop_ptr->internal_type = prop->internal_type; + prop_ptr->offset = prop->offset; + prop_ptr->count_internal = prop->count_internal; + prop_ptr->count_offset = prop->count_offset; + + /* specify that the user wants this property */ + elem->store_prop[index] = STORE_PROP; } /****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -ply_get_element_setup(). + Read one element from the file. This routine assumes that we're reading + the type of element specified in the last call to the routine + ply_get_element_setup(). -Entry: - plyfile - file identifier - elem_ptr - pointer to location where the element information should be put + Entry: + plyfile - file identifier + elem_ptr - pointer to location where the element information should be put ******************************************************************************/ void ply_get_element(PlyFile *plyfile, void *elem_ptr) { - if (plyfile->file_type == PLY_ASCII) - ascii_get_element (plyfile, (char *) elem_ptr); - else - binary_get_element (plyfile, (char *) elem_ptr); + if (plyfile->file_type == PLY_ASCII) + ascii_get_element(plyfile, (char *) elem_ptr); + else + binary_get_element(plyfile, (char *) elem_ptr); } /****************************************************************************** -Extract the comments from the header information of a PLY file. + Extract the comments from the header information of a PLY file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier -Exit: - num_comments - number of comments returned - returns a pointer to a list of comments + Exit: + num_comments - number of comments returned + returns a pointer to a list of comments ******************************************************************************/ char **ply_get_comments(PlyFile *plyfile, int *num_comments) { - *num_comments = plyfile->num_comments; - return (plyfile->comments); + *num_comments = plyfile->num_comments; + return (plyfile->comments); } /****************************************************************************** -Extract the object information (arbitrary text) from the header information -of a PLY file. + Extract the object information (arbitrary text) from the header information + of a PLY file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier -Exit: - num_obj_info - number of lines of text information returned - returns a pointer to a list of object info lines + Exit: + num_obj_info - number of lines of text information returned + returns a pointer to a list of object info lines ******************************************************************************/ char **ply_get_obj_info(PlyFile *plyfile, int *num_obj_info) { - *num_obj_info = plyfile->num_obj_info; - return (plyfile->obj_info); + *num_obj_info = plyfile->num_obj_info; + return (plyfile->obj_info); } /****************************************************************************** -Make ready for "other" properties of an element-- those properties that -the user has not explicitly asked for, but that are to be stashed away -in a special structure to be carried along with the element's other -information. - -Entry: - plyfile - file identifier - elem - element for which we want to save away other properties + Make ready for "other" properties of an element-- those properties that + the user has not explicitly asked for, but that are to be stashed away + in a special structure to be carried along with the element's other + information. + + Entry: + plyfile - file identifier + elem - element for which we want to save away other properties ******************************************************************************/ void setup_other_props(PlyElement *elem) { - int i; - PlyProperty *prop; - int size = 0; - int type_size; - - /* Examine each property in decreasing order of size. */ - /* We do this so that all data types will be aligned by */ - /* word, half-word, or whatever within the structure. */ - - for (type_size = 8; type_size > 0; type_size /= 2) { - - /* add up the space taken by each property, and save this information */ - /* away in the property descriptor */ - - for (i = 0; i < elem->nprops; i++) { - - /* don't bother with properties we've been asked to store explicitly */ - if (elem->store_prop[i]) - continue; - - prop = elem->props[i]; - - /* internal types will be same as external */ - prop->internal_type = prop->external_type; - prop->count_internal = prop->count_external; - - /* check list case */ - if (prop->is_list) { - - /* pointer to list */ - if (type_size == sizeof (void *)) { - prop->offset = size; - size += sizeof (void *); /* always use size of a pointer here */ - } - - /* count of number of list elements */ - if (type_size == ply_type_size[prop->count_external]) { - prop->count_offset = size; - size += ply_type_size[prop->count_external]; - } - } - /* not list */ - else if (type_size == ply_type_size[prop->external_type]) { - prop->offset = size; - size += ply_type_size[prop->external_type]; - } - } - - } - - /* save the size for the other_props structure */ - elem->other_size = size; + int i; + PlyProperty *prop; + int size = 0; + int type_size; + + /* Examine each property in decreasing order of size. */ + /* We do this so that all data types will be aligned by */ + /* word, half-word, or whatever within the structure. */ + + for (type_size = 8; type_size > 0; type_size /= 2) { + + /* add up the space taken by each property, and save this information */ + /* away in the property descriptor */ + + for (i = 0; i < elem->nprops; i++) { + + /* don't bother with properties we've been asked to store explicitly */ + if (elem->store_prop[i]) + continue; + + prop = elem->props[i]; + + /* internal types will be same as external */ + prop->internal_type = prop->external_type; + prop->count_internal = prop->count_external; + + /* check list case */ + if (prop->is_list) { + + /* pointer to list */ + if (type_size == sizeof(void *)) { + prop->offset = size; + size += sizeof(void *); /* always use size of a pointer here */ + } + + /* count of number of list elements */ + if (type_size == ply_type_size[prop->count_external]) { + prop->count_offset = size; + size += ply_type_size[prop->count_external]; + } + } + /* not list */ + else if (type_size == ply_type_size[prop->external_type]) { + prop->offset = size; + size += ply_type_size[prop->external_type]; + } + } + + } + + /* save the size for the other_props structure */ + elem->other_size = size; } /****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. The user needn't be concerned for how -these properties are stored. + Specify that we want the "other" properties of an element to be tucked + away within the user's structure. The user needn't be concerned for how + these properties are stored. -Entry: - plyfile - file identifier - elem_name - name of element that we want to store other_props in - offset - offset to where other_props will be stored inside user's structure + Entry: + plyfile - file identifier + elem_name - name of element that we want to store other_props in + offset - offset to where other_props will be stored inside user's structure -Exit: - returns pointer to structure containing description of other_props + Exit: + returns pointer to structure containing description of other_props ******************************************************************************/ PlyOtherProp *ply_get_other_properties( - PlyFile *plyfile, - char *elem_name, - int offset -) + PlyFile *plyfile, + char *elem_name, + int offset + ) { - int i; - PlyElement *elem; - PlyOtherProp *other; - PlyProperty *prop; - int nprops; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, "ply_get_other_properties: Can't find element '%s'\n", - elem_name); - return (NULL); - } - - /* remember that this is the "current" element */ - plyfile->which_elem = elem; - - /* save the offset to where to store the other_props */ - elem->other_offset = offset; - - /* place the appropriate pointers, etc. in the element's property list */ - setup_other_props (elem); - - /* create structure for describing other_props */ - other = (PlyOtherProp *) myalloc (sizeof (PlyOtherProp)); - other->name = strdup (elem_name); + int i; + PlyElement *elem; + PlyOtherProp *other; + PlyProperty *prop; + int nprops; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_get_other_properties: Can't find element '%s'\n", + elem_name); + return (NULL); + } + + /* remember that this is the "current" element */ + plyfile->which_elem = elem; + + /* save the offset to where to store the other_props */ + elem->other_offset = offset; + + /* place the appropriate pointers, etc. in the element's property list */ + setup_other_props(elem); + + /* create structure for describing other_props */ + other = (PlyOtherProp *) myalloc(sizeof(PlyOtherProp)); + other->name = strdup(elem_name); #if 0 - if (elem->other_offset == NO_OTHER_PROPS) { - other->size = 0; - other->props = NULL; - other->nprops = 0; - return (other); - } + if (elem->other_offset == NO_OTHER_PROPS) { + other->size = 0; + other->props = NULL; + other->nprops = 0; + return (other); + } #endif - other->size = elem->other_size; - other->props = (PlyProperty **) myalloc (sizeof(PlyProperty) * elem->nprops); + other->size = elem->other_size; + other->props = (PlyProperty **) myalloc(sizeof(PlyProperty) * elem->nprops); - /* save descriptions of each "other" property */ - nprops = 0; - for (i = 0; i < elem->nprops; i++) { - if (elem->store_prop[i]) - continue; - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - other->props[nprops] = prop; - nprops++; - } - other->nprops = nprops; + /* save descriptions of each "other" property */ + nprops = 0; + for (i = 0; i < elem->nprops; i++) { + if (elem->store_prop[i]) + continue; + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, elem->props[i]); + other->props[nprops] = prop; + nprops++; + } + other->nprops = nprops; #if 1 - /* set other_offset pointer appropriately if there are NO other properties */ - if (other->nprops == 0) { - elem->other_offset = NO_OTHER_PROPS; - } + /* set other_offset pointer appropriately if there are NO other properties */ + if (other->nprops == 0) { + elem->other_offset = NO_OTHER_PROPS; + } #endif - /* return structure */ - return (other); + /* return structure */ + return (other); } @@ -1217,151 +1217,151 @@ PlyOtherProp *ply_get_other_properties( /****************************************************************************** -Grab all the data for an element that a user does not want to explicitly -read in. + Grab all the data for an element that a user does not want to explicitly + read in. -Entry: - plyfile - pointer to file - elem_name - name of element whose data is to be read in - elem_count - number of instances of this element stored in the file + Entry: + plyfile - pointer to file + elem_name - name of element whose data is to be read in + elem_count - number of instances of this element stored in the file -Exit: - returns pointer to ALL the "other" element data for this PLY file + Exit: + returns pointer to ALL the "other" element data for this PLY file ******************************************************************************/ -PlyOtherElems *ply_get_other_element ( - PlyFile *plyfile, - char *elem_name, - int elem_count -) +PlyOtherElems *ply_get_other_element( + PlyFile *plyfile, + char *elem_name, + int elem_count + ) { - int i; - PlyElement *elem; - PlyOtherElems *other_elems; - OtherElem *other; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, - "ply_get_other_element: can't find element '%s'\n", elem_name); - exit (-1); - } - - /* create room for the new "other" element, initializing the */ - /* other data structure if necessary */ - - if (plyfile->other_elems == NULL) { - plyfile->other_elems = (PlyOtherElems *) myalloc (sizeof (PlyOtherElems)); - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) myalloc (sizeof (OtherElem)); - other = &(other_elems->other_list[0]); - other_elems->num_elems = 1; - } - else { - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) realloc (other_elems->other_list, - sizeof (OtherElem) * other_elems->num_elems + 1); - other = &(other_elems->other_list[other_elems->num_elems]); - other_elems->num_elems++; - } - - /* count of element instances in file */ - other->elem_count = elem_count; - - /* save name of element */ - other->elem_name = strdup (elem_name); - - /* create a list to hold all the current elements */ - other->other_data = (OtherData **) - malloc (sizeof (OtherData *) * other->elem_count); - - /* set up for getting elements */ - other->other_props = ply_get_other_properties (plyfile, elem_name, - offsetof(OtherData,other_props)); - - /* grab all these elements */ - for (i = 0; i < other->elem_count; i++) { - /* grab and element from the file */ - other->other_data[i] = (OtherData *) malloc (sizeof (OtherData)); - ply_get_element (plyfile, (void *) other->other_data[i]); - } - - /* return pointer to the other elements data */ - return (other_elems); + int i; + PlyElement *elem; + PlyOtherElems *other_elems; + OtherElem *other; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, + "ply_get_other_element: can't find element '%s'\n", elem_name); + exit(-1); + } + + /* create room for the new "other" element, initializing the */ + /* other data structure if necessary */ + + if (plyfile->other_elems == NULL) { + plyfile->other_elems = (PlyOtherElems *) myalloc(sizeof(PlyOtherElems)); + other_elems = plyfile->other_elems; + other_elems->other_list = (OtherElem *) myalloc(sizeof(OtherElem)); + other = &(other_elems->other_list[0]); + other_elems->num_elems = 1; + } + else { + other_elems = plyfile->other_elems; + other_elems->other_list = (OtherElem *) realloc(other_elems->other_list, + sizeof(OtherElem) * other_elems->num_elems + 1); + other = &(other_elems->other_list[other_elems->num_elems]); + other_elems->num_elems++; + } + + /* count of element instances in file */ + other->elem_count = elem_count; + + /* save name of element */ + other->elem_name = strdup(elem_name); + + /* create a list to hold all the current elements */ + other->other_data = (OtherData **) + malloc(sizeof(OtherData *) * other->elem_count); + + /* set up for getting elements */ + other->other_props = ply_get_other_properties(plyfile, elem_name, + offsetof(OtherData, other_props)); + + /* grab all these elements */ + for (i = 0; i < other->elem_count; i++) { + /* grab and element from the file */ + other->other_data[i] = (OtherData *) malloc(sizeof(OtherData)); + ply_get_element(plyfile, (void *) other->other_data[i]); + } + + /* return pointer to the other elements data */ + return (other_elems); } /****************************************************************************** -Pass along a pointer to "other" elements that we want to save in a given -PLY file. These other elements were presumably read from another PLY file. + Pass along a pointer to "other" elements that we want to save in a given + PLY file. These other elements were presumably read from another PLY file. -Entry: - plyfile - file pointer in which to store this other element info - other_elems - info about other elements that we want to store + Entry: + plyfile - file pointer in which to store this other element info + other_elems - info about other elements that we want to store ******************************************************************************/ -void ply_describe_other_elements ( - PlyFile *plyfile, - PlyOtherElems *other_elems -) +void ply_describe_other_elements( + PlyFile *plyfile, + PlyOtherElems *other_elems + ) { - int i; - OtherElem *other; + int i; + OtherElem *other; - /* ignore this call if there is no other element */ - if (other_elems == NULL) - return; + /* ignore this call if there is no other element */ + if (other_elems == NULL) + return; - /* save pointer to this information */ - plyfile->other_elems = other_elems; + /* save pointer to this information */ + plyfile->other_elems = other_elems; - /* describe the other properties of this element */ + /* describe the other properties of this element */ - for (i = 0; i < other_elems->num_elems; i++) { - other = &(other_elems->other_list[i]); - ply_element_count (plyfile, other->elem_name, other->elem_count); - ply_describe_other_properties (plyfile, other->other_props, - offsetof(OtherData,other_props)); - } + for (i = 0; i < other_elems->num_elems; i++) { + other = &(other_elems->other_list[i]); + ply_element_count(plyfile, other->elem_name, other->elem_count); + ply_describe_other_properties(plyfile, other->other_props, + offsetof(OtherData, other_props)); + } } /****************************************************************************** -Write out the "other" elements specified for this PLY file. + Write out the "other" elements specified for this PLY file. -Entry: - plyfile - pointer to PLY file to write out other elements for + Entry: + plyfile - pointer to PLY file to write out other elements for ******************************************************************************/ -void ply_put_other_elements (PlyFile *plyfile) +void ply_put_other_elements(PlyFile *plyfile) { - int i,j; - OtherElem *other; + int i, j; + OtherElem *other; - /* make sure we have other elements to write */ - if (plyfile->other_elems == NULL) - return; + /* make sure we have other elements to write */ + if (plyfile->other_elems == NULL) + return; - /* write out the data for each "other" element */ + /* write out the data for each "other" element */ - for (i = 0; i < plyfile->other_elems->num_elems; i++) { + for (i = 0; i < plyfile->other_elems->num_elems; i++) { - other = &(plyfile->other_elems->other_list[i]); - ply_put_element_setup (plyfile, other->elem_name); + other = &(plyfile->other_elems->other_list[i]); + ply_put_element_setup(plyfile, other->elem_name); - /* write out each instance of the current element */ - for (j = 0; j < other->elem_count; j++) - ply_put_element (plyfile, (void *) other->other_data[j]); - } + /* write out each instance of the current element */ + for (j = 0; j < other->elem_count; j++) + ply_put_element(plyfile, (void *) other->other_data[j]); + } } /****************************************************************************** -Free up storage used by an "other" elements data structure. + Free up storage used by an "other" elements data structure. -Entry: - other_elems - data structure to free up + Entry: + other_elems - data structure to free up ******************************************************************************/ @@ -1374,1171 +1374,1172 @@ Entry: /****************************************************************************** -Close a PLY file. + Close a PLY file. -Entry: - plyfile - identifier of file to close + Entry: + plyfile - identifier of file to close ******************************************************************************/ void ply_close(PlyFile *plyfile) { - fclose (plyfile->fp); + fclose(plyfile->fp); - /* free up memory associated with the PLY file */ - free (plyfile); + /* free up memory associated with the PLY file */ + free(plyfile); } /****************************************************************************** -Get version number and file type of a PlyFile. + Get version number and file type of a PlyFile. -Entry: - ply - pointer to PLY file + Entry: + ply - pointer to PLY file -Exit: - version - version of the file - file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE + Exit: + version - version of the file + file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE ******************************************************************************/ void ply_get_info(PlyFile *ply, float *version, int *file_type) { - if (ply == NULL) - return; + if (ply == NULL) + return; - *version = ply->version; - *file_type = ply->file_type; + *version = ply->version; + *file_type = ply->file_type; } /****************************************************************************** -Compare two strings. Returns 1 if they are the same, 0 if not. + Compare two strings. Returns 1 if they are the same, 0 if not. ******************************************************************************/ int equal_strings(char *s1, char *s2) { - while (*s1 && *s2) - if (*s1++ != *s2++) - return (0); + while (*s1 && *s2) + if (*s1++ != *s2++) + return (0); - if (*s1 != *s2) - return (0); - else - return (1); + if (*s1 != *s2) + return (0); + else + return (1); } /****************************************************************************** -Find an element from the element list of a given PLY object. + Find an element from the element list of a given PLY object. -Entry: - plyfile - file id for PLY file - element - name of element we're looking for + Entry: + plyfile - file id for PLY file + element - name of element we're looking for -Exit: - returns the element, or NULL if not found + Exit: + returns the element, or NULL if not found ******************************************************************************/ PlyElement *find_element(PlyFile *plyfile, char *element) { - int i; + int i; - for (i = 0; i < plyfile->nelems; i++) - if (equal_strings (element, plyfile->elems[i]->name)) - return (plyfile->elems[i]); + for (i = 0; i < plyfile->nelems; i++) + if (equal_strings(element, plyfile->elems[i]->name)) + return (plyfile->elems[i]); - return (NULL); + return (NULL); } /****************************************************************************** -Find a property in the list of properties of a given element. + Find a property in the list of properties of a given element. -Entry: - elem - pointer to element in which we want to find the property - prop_name - name of property to find + Entry: + elem - pointer to element in which we want to find the property + prop_name - name of property to find -Exit: - index - index to position in list - returns a pointer to the property, or NULL if not found + Exit: + index - index to position in list + returns a pointer to the property, or NULL if not found ******************************************************************************/ PlyProperty *find_property(PlyElement *elem, char *prop_name, int *index) { - int i; + int i; - for (i = 0; i < elem->nprops; i++) - if (equal_strings (prop_name, elem->props[i]->name)) { - *index = i; - return (elem->props[i]); - } + for (i = 0; i < elem->nprops; i++) + if (equal_strings(prop_name, elem->props[i]->name)) { + *index = i; + return (elem->props[i]); + } - *index = -1; - return (NULL); + *index = -1; + return (NULL); } /****************************************************************************** -Read an element from an ascii file. + Read an element from an ascii file. -Entry: - plyfile - file identifier - elem_ptr - pointer to element + Entry: + plyfile - file identifier + elem_ptr - pointer to element ******************************************************************************/ void ascii_get_element(PlyFile *plyfile, char *elem_ptr) { - int j,k; - PlyElement *elem; - PlyProperty *prop; - char **words; - int nwords; - int which_word; - char *elem_data,*item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *orig_line; - char *other_data; - int other_flag; - - other_flag = 0; + int j, k; + PlyElement *elem; + PlyProperty *prop; + char **words; + int nwords; + int which_word; + char *elem_data, *item; + char *item_ptr; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + int list_count; + int store_it; + char **store_array; + char *orig_line; + char *other_data; + int other_flag; + + other_flag = 0; other_data = NULL; item = NULL; item_size = 0; - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - char **ptr; - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - /* store pointer in user's structure to the other_props */ - ptr = (char **) (elem_ptr + elem->other_offset); - *ptr = other_data; - } else { - other_flag = 0; - other_data = NULL; - item = NULL; - item_size = 0; - } - - /* read in the element */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (words == NULL) { - fprintf (stderr, "ply_get_element: unexpected end of file\n"); - exit (-1); - } - - which_word = 0; - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else - elem_data = other_data; - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_ascii_item (words[which_word++], prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = (char **) (elem_data + prop->offset); - - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } - - free (words); + /* the kind of element we're reading currently */ + elem = plyfile->which_elem; + + /* do we need to setup for other_props? */ + + if (elem->other_offset != NO_OTHER_PROPS) { + char **ptr; + other_flag = 1; + /* make room for other_props */ + other_data = (char *) myalloc(elem->other_size); + /* store pointer in user's structure to the other_props */ + ptr = (char **) (elem_ptr + elem->other_offset); + *ptr = other_data; + } + else { + other_flag = 0; + other_data = NULL; + item = NULL; + item_size = 0; + } + + /* read in the element */ + + words = get_words(plyfile->fp, &nwords, &orig_line); + if (words == NULL) { + fprintf(stderr, "ply_get_element: unexpected end of file\n"); + exit(-1); + } + + which_word = 0; + + for (j = 0; j < elem->nprops; j++) { + + prop = elem->props[j]; + store_it = (elem->store_prop[j] | other_flag); + + /* store either in the user's structure or in other_props */ + if (elem->store_prop[j]) + elem_data = elem_ptr; + else + elem_data = other_data; + + if (prop->is_list) { /* a list */ + + /* get and store the number of items in the list */ + get_ascii_item(words[which_word++], prop->count_external, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->count_offset; + store_item(item, prop->count_internal, int_val, uint_val, double_val); + } + + /* allocate space for an array of items and store a ptr to the array */ + list_count = int_val; + item_size = ply_type_size[prop->internal_type]; + store_array = (char **) (elem_data + prop->offset); + + if (list_count == 0) { + if (store_it) + *store_array = NULL; + } + else { + if (store_it) { + item_ptr = (char *) myalloc(sizeof(char) * item_size * list_count); + item = item_ptr; + *store_array = item_ptr; + } + + /* read items and store them into the array */ + for (k = 0; k < list_count; k++) { + get_ascii_item(words[which_word++], prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + store_item(item, prop->internal_type, + int_val, uint_val, double_val); + item += item_size; + } + } + } + + } + else { /* not a list */ + get_ascii_item(words[which_word++], prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->offset; + store_item(item, prop->internal_type, int_val, uint_val, double_val); + } + } + + } + + free(words); } /****************************************************************************** -Read an element from a binary file. + Read an element from a binary file. -Entry: - plyfile - file identifier - elem_ptr - pointer to an element + Entry: + plyfile - file identifier + elem_ptr - pointer to an element ******************************************************************************/ void binary_get_element(PlyFile *plyfile, char *elem_ptr) { - int j,k; - PlyElement *elem; - PlyProperty *prop; - FILE *fp = plyfile->fp; - char *elem_data,*item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *other_data; - int other_flag; - - - other_flag = 0; - other_data = NULL; - item = NULL; - item_size = 0; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - char **ptr; - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - /* store pointer in user's structure to the other_props */ - ptr = (char **) (elem_ptr + elem->other_offset); - *ptr = other_data; - } - else { - other_flag = 0; + int j, k; + PlyElement *elem; + PlyProperty *prop; + FILE *fp = plyfile->fp; + char *elem_data, *item; + char *item_ptr; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + int list_count; + int store_it; + char **store_array; + char *other_data; + int other_flag; + + + other_flag = 0; other_data = NULL; item = NULL; item_size = 0; - } - /* read in a number of elements */ - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else - elem_data = other_data; - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_binary_item (fp, prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - /* The "if" was added by Afra Zomorodian 8/22/95 - * so that zipper won't crash reading plies that have additional - * properties. - */ - if (store_it) { - item_size = ply_type_size[prop->internal_type]; - } - store_array = (char **) (elem_data + prop->offset); - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_binary_item (fp, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_binary_item (fp, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } + + /* the kind of element we're reading currently */ + elem = plyfile->which_elem; + + /* do we need to setup for other_props? */ + + if (elem->other_offset != NO_OTHER_PROPS) { + char **ptr; + other_flag = 1; + /* make room for other_props */ + other_data = (char *) myalloc(elem->other_size); + /* store pointer in user's structure to the other_props */ + ptr = (char **) (elem_ptr + elem->other_offset); + *ptr = other_data; + } + else { + other_flag = 0; + other_data = NULL; + item = NULL; + item_size = 0; + } + /* read in a number of elements */ + + for (j = 0; j < elem->nprops; j++) { + + prop = elem->props[j]; + store_it = (elem->store_prop[j] | other_flag); + + /* store either in the user's structure or in other_props */ + if (elem->store_prop[j]) + elem_data = elem_ptr; + else + elem_data = other_data; + + if (prop->is_list) { /* a list */ + + /* get and store the number of items in the list */ + get_binary_item(fp, prop->count_external, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->count_offset; + store_item(item, prop->count_internal, int_val, uint_val, double_val); + } + + /* allocate space for an array of items and store a ptr to the array */ + list_count = int_val; + /* The "if" was added by Afra Zomorodian 8/22/95 + * so that zipper won't crash reading plies that have additional + * properties. + */ + if (store_it) { + item_size = ply_type_size[prop->internal_type]; + } + store_array = (char **) (elem_data + prop->offset); + if (list_count == 0) { + if (store_it) + *store_array = NULL; + } + else { + if (store_it) { + item_ptr = (char *) myalloc(sizeof(char) * item_size * list_count); + item = item_ptr; + *store_array = item_ptr; + } + + /* read items and store them into the array */ + for (k = 0; k < list_count; k++) { + get_binary_item(fp, prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + store_item(item, prop->internal_type, + int_val, uint_val, double_val); + item += item_size; + } + } + } + + } + else { /* not a list */ + get_binary_item(fp, prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->offset; + store_item(item, prop->internal_type, int_val, uint_val, double_val); + } + } + + } } /****************************************************************************** -Write to a file the word that represents a PLY data type. + Write to a file the word that represents a PLY data type. -Entry: - fp - file pointer - code - code for type + Entry: + fp - file pointer + code - code for type ******************************************************************************/ -void write_scalar_type (FILE *fp, int code) +void write_scalar_type(FILE *fp, int code) { - /* make sure this is a valid code */ + /* make sure this is a valid code */ - if (code <= PLY_START_TYPE || code >= PLY_END_TYPE) { - fprintf (stderr, "write_scalar_type: bad data code = %d\n", code); - exit (-1); - } + if (code <= PLY_START_TYPE || code >= PLY_END_TYPE) { + fprintf(stderr, "write_scalar_type: bad data code = %d\n", code); + exit(-1); + } - /* write the code to a file */ + /* write the code to a file */ - fprintf (fp, "%s", type_names[code]); + fprintf(fp, "%s", type_names[code]); } /****************************************************************************** -Get a text line from a file and break it up into words. + Get a text line from a file and break it up into words. -IMPORTANT: The calling routine call "free" on the returned pointer once -finished with it. + IMPORTANT: The calling routine call "free" on the returned pointer once + finished with it. -Entry: - fp - file to read from + Entry: + fp - file to read from -Exit: - nwords - number of words returned - orig_line - the original line of characters - returns a list of words from the line, or NULL if end-of-file + Exit: + nwords - number of words returned + orig_line - the original line of characters + returns a list of words from the line, or NULL if end-of-file ******************************************************************************/ char **get_words(FILE *fp, int *nwords, char **orig_line) { #define BIG_STRING 4096 - static char str[BIG_STRING]; - static char str_copy[BIG_STRING]; - char **words; - int max_words = 10; - int num_words = 0; - char *ptr,*ptr2; - char *result; - - words = (char **) myalloc (sizeof (char *) * max_words); - - /* read in a line */ - result = fgets (str, BIG_STRING, fp); - if (result == NULL) { - *nwords = 0; - *orig_line = NULL; - return (NULL); - } - - /* convert line-feed and tabs into spaces */ - /* (this guarentees that there will be a space before the */ - /* null character at the end of the string) */ - - str[BIG_STRING-2] = ' '; - str[BIG_STRING-1] = '\0'; - - for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) { - *ptr2 = *ptr; - if (*ptr == '\t') { - *ptr = ' '; - *ptr2 = ' '; - } - else if (*ptr == '\n') { - *ptr = ' '; - *ptr2 = '\0'; - break; - } - } - - /* find the words in the line */ - - ptr = str; - while (*ptr != '\0') { - - /* jump over leading spaces */ - while (*ptr == ' ') - ptr++; - - /* break if we reach the end */ - if (*ptr == '\0') - break; - - /* save pointer to beginning of word */ - if (num_words >= max_words) { - max_words += 10; - words = (char **) realloc (words, sizeof (char *) * max_words); - } - words[num_words++] = ptr; - - /* jump over non-spaces */ - while (*ptr != ' ') - ptr++; - - /* place a null character here to mark the end of the word */ - *ptr++ = '\0'; - } - - /* return the list of words */ - *nwords = num_words; - *orig_line = str_copy; - return (words); + static char str[BIG_STRING]; + static char str_copy[BIG_STRING]; + char **words; + int max_words = 10; + int num_words = 0; + char *ptr, *ptr2; + char *result; + + words = (char **) myalloc(sizeof(char *) * max_words); + + /* read in a line */ + result = fgets(str, BIG_STRING, fp); + if (result == NULL) { + *nwords = 0; + *orig_line = NULL; + return (NULL); + } + + /* convert line-feed and tabs into spaces */ + /* (this guarentees that there will be a space before the */ + /* null character at the end of the string) */ + + str[BIG_STRING - 2] = ' '; + str[BIG_STRING - 1] = '\0'; + + for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) { + *ptr2 = *ptr; + if (*ptr == '\t') { + *ptr = ' '; + *ptr2 = ' '; + } + else if (*ptr == '\n') { + *ptr = ' '; + *ptr2 = '\0'; + break; + } + } + + /* find the words in the line */ + + ptr = str; + while (*ptr != '\0') { + + /* jump over leading spaces */ + while (*ptr == ' ') + ptr++; + + /* break if we reach the end */ + if (*ptr == '\0') + break; + + /* save pointer to beginning of word */ + if (num_words >= max_words) { + max_words += 10; + words = (char **) realloc(words, sizeof(char *) * max_words); + } + words[num_words++] = ptr; + + /* jump over non-spaces */ + while (*ptr != ' ') + ptr++; + + /* place a null character here to mark the end of the word */ + *ptr++ = '\0'; + } + + /* return the list of words */ + *nwords = num_words; + *orig_line = str_copy; + return (words); } /****************************************************************************** -Return the value of an item, given a pointer to it and its type. + Return the value of an item, given a pointer to it and its type. -Entry: - item - pointer to item - type - data type that "item" points to + Entry: + item - pointer to item + type - data type that "item" points to -Exit: - returns a double-precision float that contains the value of the item + Exit: + returns a double-precision float that contains the value of the item ******************************************************************************/ double get_item_value(char *item, int type) { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - return (double_value); - default: - fprintf (stderr, "get_item_value: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + char *pchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + int int_value; + unsigned int uint_value; + double double_value; + + switch (type) { + case PLY_CHAR: + pchar = (char *) item; + int_value = *pchar; + return ((double) int_value); + case PLY_UCHAR: + puchar = (unsigned char *) item; + int_value = *puchar; + return ((double) int_value); + case PLY_SHORT: + pshort = (short int *) item; + int_value = *pshort; + return ((double) int_value); + case PLY_USHORT: + pushort = (unsigned short int *) item; + int_value = *pushort; + return ((double) int_value); + case PLY_INT: + pint = (int *) item; + int_value = *pint; + return ((double) int_value); + case PLY_UINT: + puint = (unsigned int *) item; + uint_value = *puint; + return ((double) uint_value); + case PLY_FLOAT: + pfloat = (float *) item; + double_value = *pfloat; + return (double_value); + case PLY_DOUBLE: + pdouble = (double *) item; + double_value = *pdouble; + return (double_value); + default: + fprintf(stderr, "get_item_value: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as raw binary bytes. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out + Write out an item to a file as raw binary bytes. + + Entry: + fp - file to write to + int_val - integer version of item + uint_val - unsigned integer version of item + double_val - double-precision float version of item + type - data type to write out ******************************************************************************/ void write_binary_item( - FILE *fp, - int int_val, - unsigned int uint_val, - double double_val, - int type -) + FILE *fp, + int int_val, + unsigned int uint_val, + double double_val, + int type + ) { - unsigned char uchar_val; - char char_val; - unsigned short ushort_val; - short short_val; - float float_val; - - switch (type) { - case PLY_CHAR: - char_val = (char)int_val; - fwrite (&char_val, 1, 1, fp); - break; - case PLY_SHORT: - short_val = (short)int_val; - fwrite (&short_val, 2, 1, fp); - break; - case PLY_INT: - fwrite (&int_val, 4, 1, fp); - break; - case PLY_UCHAR: - uchar_val = (unsigned char) uint_val; - fwrite (&uchar_val, 1, 1, fp); - break; - case PLY_USHORT: - ushort_val = (unsigned short)uint_val; - fwrite (&ushort_val, 2, 1, fp); - break; - case PLY_UINT: - fwrite (&uint_val, 4, 1, fp); - break; - case PLY_FLOAT: - float_val = (float) double_val; - fwrite (&float_val, 4, 1, fp); - break; - case PLY_DOUBLE: - fwrite (&double_val, 8, 1, fp); - break; - default: - fprintf (stderr, "write_binary_item: bad type = %d\n", type); - exit (-1); - } + unsigned char uchar_val; + char char_val; + unsigned short ushort_val; + short short_val; + float float_val; + + switch (type) { + case PLY_CHAR: + char_val = (char)int_val; + fwrite(&char_val, 1, 1, fp); + break; + case PLY_SHORT: + short_val = (short)int_val; + fwrite(&short_val, 2, 1, fp); + break; + case PLY_INT: + fwrite(&int_val, 4, 1, fp); + break; + case PLY_UCHAR: + uchar_val = (unsigned char) uint_val; + fwrite(&uchar_val, 1, 1, fp); + break; + case PLY_USHORT: + ushort_val = (unsigned short)uint_val; + fwrite(&ushort_val, 2, 1, fp); + break; + case PLY_UINT: + fwrite(&uint_val, 4, 1, fp); + break; + case PLY_FLOAT: + float_val = (float) double_val; + fwrite(&float_val, 4, 1, fp); + break; + case PLY_DOUBLE: + fwrite(&double_val, 8, 1, fp); + break; + default: + fprintf(stderr, "write_binary_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out + Write out an item to a file as ascii characters. + + Entry: + fp - file to write to + int_val - integer version of item + uint_val - unsigned integer version of item + double_val - double-precision float version of item + type - data type to write out ******************************************************************************/ void write_ascii_item( - FILE *fp, - int int_val, - unsigned int uint_val, - double double_val, - int type -) + FILE *fp, + int int_val, + unsigned int uint_val, + double double_val, + int type + ) { - switch (type) { - case PLY_CHAR: - case PLY_SHORT: - case PLY_INT: - fprintf (fp, "%d ", int_val); - break; - case PLY_UCHAR: - case PLY_USHORT: - case PLY_UINT: - fprintf (fp, "%u ", uint_val); - break; - case PLY_FLOAT: - case PLY_DOUBLE: - fprintf (fp, "%g ", double_val); - break; - default: - fprintf (stderr, "write_ascii_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + case PLY_SHORT: + case PLY_INT: + fprintf(fp, "%d ", int_val); + break; + case PLY_UCHAR: + case PLY_USHORT: + case PLY_UINT: + fprintf(fp, "%u ", uint_val); + break; + case PLY_FLOAT: + case PLY_DOUBLE: + fprintf(fp, "%g ", double_val); + break; + default: + fprintf(stderr, "write_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as ascii characters. + Write out an item to a file as ascii characters. -Entry: - fp - file to write to - item - pointer to item to write - type - data type that "item" points to + Entry: + fp - file to write to + item - pointer to item to write + type - data type that "item" points to -Exit: - returns a double-precision float that contains the value of the written item + Exit: + returns a double-precision float that contains the value of the written item ******************************************************************************/ double old_write_ascii_item(FILE *fp, char *item, int type) { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - fprintf (fp, "%u ", uint_value); - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - fprintf (fp, "%g ", double_value); - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - fprintf (fp, "%g ", double_value); - return (double_value); - default: - fprintf (stderr, "old_write_ascii_item: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + char *pchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + int int_value; + unsigned int uint_value; + double double_value; + + switch (type) { + case PLY_CHAR: + pchar = (char *) item; + int_value = *pchar; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_UCHAR: + puchar = (unsigned char *) item; + int_value = *puchar; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_SHORT: + pshort = (short int *) item; + int_value = *pshort; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_USHORT: + pushort = (unsigned short int *) item; + int_value = *pushort; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_INT: + pint = (int *) item; + int_value = *pint; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_UINT: + puint = (unsigned int *) item; + uint_value = *puint; + fprintf(fp, "%u ", uint_value); + return ((double) uint_value); + case PLY_FLOAT: + pfloat = (float *) item; + double_value = *pfloat; + fprintf(fp, "%g ", double_value); + return (double_value); + case PLY_DOUBLE: + pdouble = (double *) item; + double_value = *pdouble; + fprintf(fp, "%g ", double_value); + return (double_value); + default: + fprintf(stderr, "old_write_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Get the value of an item that is in memory, and place the result -into an integer, an unsigned integer and a double. + Get the value of an item that is in memory, and place the result + into an integer, an unsigned integer and a double. -Entry: - ptr - pointer to the item - type - data type supposedly in the item + Entry: + ptr - pointer to the item + type - data type supposedly in the item -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_stored_item( - void *ptr, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + void *ptr, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - switch (type) { - case PLY_CHAR: - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - *double_val = *((float *) ptr); - *int_val = (int)*double_val; - *uint_val = (unsigned int)*double_val; - break; - case PLY_DOUBLE: - *double_val = *((double *) ptr); - *int_val = (int)*double_val; - *uint_val =(unsigned int) *double_val; - break; - default: - fprintf (stderr, "get_stored_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + *int_val = *((char *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UCHAR: + *uint_val = *((unsigned char *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_SHORT: + *int_val = *((short int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_USHORT: + *uint_val = *((unsigned short int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_INT: + *int_val = *((int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UINT: + *uint_val = *((unsigned int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_FLOAT: + *double_val = *((float *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int)*double_val; + break; + case PLY_DOUBLE: + *double_val = *((double *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int) *double_val; + break; + default: + fprintf(stderr, "get_stored_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Get the value of an item from a binary file, and place the result -into an integer, an unsigned integer and a double. + Get the value of an item from a binary file, and place the result + into an integer, an unsigned integer and a double. -Entry: - fp - file to get item from - type - data type supposedly in the word + Entry: + fp - file to get item from + type - data type supposedly in the word -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_binary_item( - FILE *fp, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + FILE *fp, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - char c[8]; - void *ptr; - - ptr = (void *) c; - - switch (type) { - case PLY_CHAR: - fread (ptr, 1, 1, fp); - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - fread (ptr, 1, 1, fp); - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - fread (ptr, 2, 1, fp); - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - fread (ptr, 2, 1, fp); - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - fread (ptr, 4, 1, fp); - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - fread (ptr, 4, 1, fp); - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - fread (ptr, 4, 1, fp); - *double_val = *((float *) ptr); - *int_val = (int)*double_val; - *uint_val =(unsigned int) *double_val; - break; - case PLY_DOUBLE: - fread (ptr, 8, 1, fp); - *double_val = *((double *) ptr); - *int_val = (int)*double_val; - *uint_val = (unsigned int)*double_val; - break; - default: - fprintf (stderr, "get_binary_item: bad type = %d\n", type); - exit (-1); - } + char c[8]; + void *ptr; + + ptr = (void *) c; + + switch (type) { + case PLY_CHAR: + fread(ptr, 1, 1, fp); + *int_val = *((char *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UCHAR: + fread(ptr, 1, 1, fp); + *uint_val = *((unsigned char *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_SHORT: + fread(ptr, 2, 1, fp); + *int_val = *((short int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_USHORT: + fread(ptr, 2, 1, fp); + *uint_val = *((unsigned short int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_INT: + fread(ptr, 4, 1, fp); + *int_val = *((int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UINT: + fread(ptr, 4, 1, fp); + *uint_val = *((unsigned int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_FLOAT: + fread(ptr, 4, 1, fp); + *double_val = *((float *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int) *double_val; + break; + case PLY_DOUBLE: + fread(ptr, 8, 1, fp); + *double_val = *((double *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int)*double_val; + break; + default: + fprintf(stderr, "get_binary_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Extract the value of an item from an ascii word, and place the result -into an integer, an unsigned integer and a double. + Extract the value of an item from an ascii word, and place the result + into an integer, an unsigned integer and a double. -Entry: - word - word to extract value from - type - data type supposedly in the word + Entry: + word - word to extract value from + type - data type supposedly in the word -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_ascii_item( - char *word, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + char *word, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - switch (type) { - case PLY_CHAR: - case PLY_UCHAR: - case PLY_SHORT: - case PLY_USHORT: - case PLY_INT: - *int_val = atoi (word); - *uint_val = *int_val; - *double_val = *int_val; - break; - - case PLY_UINT: - *uint_val = strtoul (word, (char **) NULL, 10); - *int_val = *uint_val; - *double_val = *uint_val; - break; - - case PLY_FLOAT: - case PLY_DOUBLE: - *double_val = atof (word); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - - default: - fprintf (stderr, "get_ascii_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + case PLY_UCHAR: + case PLY_SHORT: + case PLY_USHORT: + case PLY_INT: + *int_val = atoi(word); + *uint_val = *int_val; + *double_val = *int_val; + break; + + case PLY_UINT: + *uint_val = strtoul(word, (char **) NULL, 10); + *int_val = *uint_val; + *double_val = *uint_val; + break; + + case PLY_FLOAT: + case PLY_DOUBLE: + *double_val = atof(word); + *int_val = (int) *double_val; + *uint_val = (unsigned int) *double_val; + break; + + default: + fprintf(stderr, "get_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Store a value into a place being pointed to, guided by a data type. + Store a value into a place being pointed to, guided by a data type. -Entry: - item - place to store value - type - data type - int_val - integer version of value - uint_val - unsigned integer version of value - double_val - double version of value + Entry: + item - place to store value + type - data type + int_val - integer version of value + uint_val - unsigned integer version of value + double_val - double version of value -Exit: - item - pointer to stored value + Exit: + item - pointer to stored value ******************************************************************************/ -void store_item ( - char *item, - int type, - int int_val, - unsigned int uint_val, - double double_val -) +void store_item( + char *item, + int type, + int int_val, + unsigned int uint_val, + double double_val + ) { - unsigned char *puchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - - switch (type) { - case PLY_CHAR: - *item = (char) int_val; - break; - case PLY_UCHAR: - puchar = (unsigned char *) item; - *puchar = (unsigned char)uint_val; - break; - case PLY_SHORT: - pshort = (short *) item; - *pshort = (short)int_val; - break; - case PLY_USHORT: - pushort = (unsigned short *) item; - *pushort = (unsigned short)uint_val; - break; - case PLY_INT: - pint = (int *) item; - *pint = int_val; - break; - case PLY_UINT: - puint = (unsigned int *) item; - *puint = uint_val; - break; - case PLY_FLOAT: - pfloat = (float *) item; - *pfloat = (float)double_val; - break; - case PLY_DOUBLE: - pdouble = (double *) item; - *pdouble = double_val; - break; - default: - fprintf (stderr, "store_item: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + + switch (type) { + case PLY_CHAR: + *item = (char) int_val; + break; + case PLY_UCHAR: + puchar = (unsigned char *) item; + *puchar = (unsigned char)uint_val; + break; + case PLY_SHORT: + pshort = (short *) item; + *pshort = (short)int_val; + break; + case PLY_USHORT: + pushort = (unsigned short *) item; + *pushort = (unsigned short)uint_val; + break; + case PLY_INT: + pint = (int *) item; + *pint = int_val; + break; + case PLY_UINT: + puint = (unsigned int *) item; + *puint = uint_val; + break; + case PLY_FLOAT: + pfloat = (float *) item; + *pfloat = (float)double_val; + break; + case PLY_DOUBLE: + pdouble = (double *) item; + *pdouble = double_val; + break; + default: + fprintf(stderr, "store_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Add an element to a PLY file descriptor. + Add an element to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - words - list of words describing the element - nwords - number of words in the list + Entry: + plyfile - PLY file descriptor + words - list of words describing the element + nwords - number of words in the list ******************************************************************************/ -void add_element (PlyFile *plyfile, char **words) +void add_element(PlyFile *plyfile, char **words) { - PlyElement *elem; - - /* create the new element */ - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - elem->name = strdup (words[1]); - elem->num = atoi (words[2]); - elem->nprops = 0; - - /* make room for new element in the object's list of elements */ - if (plyfile->nelems == 0) - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *)); - else - plyfile->elems = (PlyElement **) realloc (plyfile->elems, - sizeof (PlyElement *) * (plyfile->nelems + 1)); - - /* add the new element to the object's list */ - plyfile->elems[plyfile->nelems] = elem; - plyfile->nelems++; + PlyElement *elem; + + /* create the new element */ + elem = (PlyElement *) myalloc(sizeof(PlyElement)); + elem->name = strdup(words[1]); + elem->num = atoi(words[2]); + elem->nprops = 0; + + /* make room for new element in the object's list of elements */ + if (plyfile->nelems == 0) + plyfile->elems = (PlyElement **) myalloc(sizeof(PlyElement *)); + else + plyfile->elems = (PlyElement **) realloc(plyfile->elems, + sizeof(PlyElement *) * (plyfile->nelems + 1)); + + /* add the new element to the object's list */ + plyfile->elems[plyfile->nelems] = elem; + plyfile->nelems++; } /****************************************************************************** -Return the type of a property, given the name of the property. + Return the type of a property, given the name of the property. -Entry: - name - name of property type + Entry: + name - name of property type -Exit: - returns integer code for property, or 0 if not found + Exit: + returns integer code for property, or 0 if not found ******************************************************************************/ int get_prop_type(char *type_name) { - int i; + int i; - for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++) - if (equal_strings (type_name, type_names[i])) - return (i); + for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++) + if (equal_strings(type_name, type_names[i])) + return (i); - /* if we get here, we didn't find the type */ - return (0); + /* if we get here, we didn't find the type */ + return (0); } /****************************************************************************** -Add a property to a PLY file descriptor. + Add a property to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - words - list of words describing the property - nwords - number of words in the list + Entry: + plyfile - PLY file descriptor + words - list of words describing the property + nwords - number of words in the list ******************************************************************************/ -void add_property (PlyFile *plyfile, char **words) +void add_property(PlyFile *plyfile, char **words) { - PlyProperty *prop; - PlyElement *elem; + PlyProperty *prop; + PlyElement *elem; - /* create the new property */ + /* create the new property */ - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); - if (equal_strings (words[1], "list")) { /* is a list */ - prop->count_external = get_prop_type (words[2]); - prop->external_type = get_prop_type (words[3]); - prop->name = strdup (words[4]); - prop->is_list = 1; - } - else { /* not a list */ - prop->external_type = get_prop_type (words[1]); - prop->name = strdup (words[2]); - prop->is_list = 0; - } + if (equal_strings(words[1], "list")) { /* is a list */ + prop->count_external = get_prop_type(words[2]); + prop->external_type = get_prop_type(words[3]); + prop->name = strdup(words[4]); + prop->is_list = 1; + } + else { /* not a list */ + prop->external_type = get_prop_type(words[1]); + prop->name = strdup(words[2]); + prop->is_list = 0; + } - /* add this property to the list of properties of the current element */ + /* add this property to the list of properties of the current element */ - elem = plyfile->elems[plyfile->nelems - 1]; + elem = plyfile->elems[plyfile->nelems - 1]; - if (elem->nprops == 0) - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - else - elem->props = (PlyProperty **) realloc (elem->props, - sizeof (PlyProperty *) * (elem->nprops + 1)); + if (elem->nprops == 0) + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *)); + else + elem->props = (PlyProperty **) realloc(elem->props, + sizeof(PlyProperty *) * (elem->nprops + 1)); - elem->props[elem->nprops] = prop; - elem->nprops++; + elem->props[elem->nprops] = prop; + elem->nprops++; } /****************************************************************************** -Add a comment to a PLY file descriptor. + Add a comment to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - line - line containing comment + Entry: + plyfile - PLY file descriptor + line - line containing comment ******************************************************************************/ -void add_comment (PlyFile *plyfile, char *line) +void add_comment(PlyFile *plyfile, char *line) { - int i; + int i; - /* skip over "comment" and leading spaces and tabs */ - i = 7; - while (line[i] == ' ' || line[i] == '\t') - i++; + /* skip over "comment" and leading spaces and tabs */ + i = 7; + while (line[i] == ' ' || line[i] == '\t') + i++; - ply_put_comment (plyfile, &line[i]); + ply_put_comment(plyfile, &line[i]); } /****************************************************************************** -Add a some object information to a PLY file descriptor. + Add a some object information to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - line - line containing text info + Entry: + plyfile - PLY file descriptor + line - line containing text info ******************************************************************************/ -void add_obj_info (PlyFile *plyfile, char *line) +void add_obj_info(PlyFile *plyfile, char *line) { - int i; + int i; - /* skip over "obj_info" and leading spaces and tabs */ - i = 8; - while (line[i] == ' ' || line[i] == '\t') - i++; + /* skip over "obj_info" and leading spaces and tabs */ + i = 8; + while (line[i] == ' ' || line[i] == '\t') + i++; - ply_put_obj_info (plyfile, &line[i]); + ply_put_obj_info(plyfile, &line[i]); } /****************************************************************************** -Copy a property. + Copy a property. ******************************************************************************/ void copy_property(PlyProperty *dest, PlyProperty *src) { - dest->name = strdup (src->name); - dest->external_type = src->external_type; - dest->internal_type = src->internal_type; - dest->offset = src->offset; - - dest->is_list = src->is_list; - dest->count_external = src->count_external; - dest->count_internal = src->count_internal; - dest->count_offset = src->count_offset; + dest->name = strdup(src->name); + dest->external_type = src->external_type; + dest->internal_type = src->internal_type; + dest->offset = src->offset; + + dest->is_list = src->is_list; + dest->count_external = src->count_external; + dest->count_internal = src->count_internal; + dest->count_offset = src->count_offset; } /****************************************************************************** -Allocate some memory. + Allocate some memory. -Entry: - size - amount of memory requested (in bytes) - lnum - line number from which memory was requested - fname - file name from which memory was requested + Entry: + size - amount of memory requested (in bytes) + lnum - line number from which memory was requested + fname - file name from which memory was requested ******************************************************************************/ static char *my_alloc(int size, int lnum, char *fname) { - char *ptr; + char *ptr; - ptr = (char *) malloc (size); + ptr = (char *) malloc(size); - if (ptr == 0) { - fprintf(stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname); - } + if (ptr == 0) { + fprintf(stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname); + } - return (ptr); + return (ptr); } diff --git a/intern/elbeem/intern/controlparticles.cpp b/intern/elbeem/intern/controlparticles.cpp index 7f43ba60614..526fac0cc6b 100644 --- a/intern/elbeem/intern/controlparticles.cpp +++ b/intern/elbeem/intern/controlparticles.cpp @@ -665,11 +665,11 @@ int ControlParticles::initFromBinaryFile(string filename) { int ptype=0; float psize=0.0; ntlVec3Gfx ppos,pvel; - gzread(gzf, &ptype, sizeof( ptype )); - gzread(gzf, &psize, sizeof( float )); + gzread(gzf, &ptype, sizeof(ptype)); + gzread(gzf, &psize, sizeof(float)); - for(int j=0; j<3; j++) { gzread(gzf, &ppos[j], sizeof( float )); } - for(int j=0; j<3; j++) { gzread(gzf, &pvel[j], sizeof( float )); } + for (int j=0; j<3; j++) { gzread(gzf, &ppos[j], sizeof(float)); } + for (int j=0; j<3; j++) { gzread(gzf, &pvel[j], sizeof(float)); } ControlParticle p; p.reset(); diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index a647f82a325..c2456fed800 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -639,8 +639,8 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow) { GHOST_TInt32 x_screen, y_screen; - GHOST_SystemWin32 *system = ((GHOST_SystemWin32 * ) getSystem()); - GHOST_WindowWin32 *window = ( GHOST_WindowWin32 * ) Iwindow; + GHOST_SystemWin32 *system = (GHOST_SystemWin32 *) getSystem(); + GHOST_WindowWin32 *window = (GHOST_WindowWin32 *) Iwindow; system->getCursorPosition(x_screen, y_screen); diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c index 4086fbba730..c32d78f0358 100644 --- a/intern/ghost/test/gears/GHOST_C-Test.c +++ b/intern/ghost/test/gears/GHOST_C-Test.c @@ -526,7 +526,6 @@ int main(int argc, char **argv) /* Dispose the system */ GHOST_DisposeSystem(shSystem); - GHOST_DisposeEventConsumer(consumer); return 0; } diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp index c51b72ad271..d338f11ddde 100644 --- a/intern/ghost/test/gears/GHOST_Test.cpp +++ b/intern/ghost/test/gears/GHOST_Test.cpp @@ -435,7 +435,7 @@ Application::Application(GHOST_ISystem *system) m_secondaryWindow = system->createWindow(title2, 340, 64, 320, 200, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, false, false); if (!m_secondaryWindow) { - cout << "could not create secondary window\n"; + std::cout << "could not create secondary window\n"; exit(-1); } diff --git a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp index 0ec1ccddb15..cfa6a207e1c 100644 --- a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp +++ b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp @@ -58,12 +58,12 @@ public: MEM_CacheLimiterCClass(MEM_CacheLimiter_Destruct_Func data_destructor_, MEM_CacheLimiter_DataSize_Func data_size) : data_destructor(data_destructor_), cache(data_size) { } - ~MEM_CacheLimiterCClass(); + ~MEM_CacheLimiterCClass(); handle_t * insert(void * data); void destruct(void * data, - list_t::iterator it); + list_t::iterator it); cache_t * get_cache() { return &cache; @@ -79,9 +79,9 @@ private: class MEM_CacheLimiterHandleCClass { public: MEM_CacheLimiterHandleCClass(void * data_, - MEM_CacheLimiterCClass * parent_) - : data(data_), parent(parent_) { } - ~MEM_CacheLimiterHandleCClass(); + MEM_CacheLimiterCClass * parent_) + : data(data_), parent(parent_) { } + ~MEM_CacheLimiterHandleCClass(); void set_iter(list_t::iterator it_) { it = it_; } diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index e00982bae72..3d04db56d43 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -452,7 +452,7 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) return AVI_ERROR_FORMAT; } - movie->header = (AviMainHeader *) MEM_mallocN(sizeof (AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof(AviMainHeader), "movieheader"); if (GET_FCC(movie->fp) != FCC("AVI ") || GET_FCC(movie->fp) != FCC("LIST") || @@ -769,7 +769,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) if (movie->fp == NULL) return AVI_ERROR_OPEN; - movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof (int64_t), "offsettable"); + movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof(int64_t), "offsettable"); for (i = 0; i < 1 + streams * 2; i++) movie->offset_table[i] = -1L; diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index d26a722b628..48dbd590cfe 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1878,8 +1878,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, /* r = co * 0.75 + q * 0.25 */ VertDataCopy(r, co, ss); - VertDataMulN(r, .75f, ss); - VertDataMulN(q, .25f, ss); + VertDataMulN(r, 0.75f, ss); + VertDataMulN(q, 0.25f, ss); VertDataAdd(r, q, ss); /* nCo = nCo + (r - nCo) * avgSharpness */ diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b681426f8a7..a0cca25a841 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1007,7 +1007,7 @@ int cloth_add_spring(ClothModifierData *clmd, unsigned int indexA, unsigned int if (cloth) { // TODO: look if this spring is already there - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) return 0; @@ -1079,7 +1079,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) cloth->springs = NULL; - edgelist = MEM_callocN ( sizeof ( LinkNode * ) * numverts, "cloth_edgelist_alloc" ); + edgelist = MEM_callocN ( sizeof (LinkNode *) * numverts, "cloth_edgelist_alloc" ); if (!edgelist) return 0; @@ -1096,7 +1096,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // structural springs for ( i = 0; i < numedges; i++ ) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if ( spring ) { spring->ij = MIN2(medge[i].v1, medge[i].v2); @@ -1154,7 +1154,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // if ( mface[i].v4 ) --> Quad face - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); @@ -1192,7 +1192,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) && (index2 != tspring2->ij)) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); @@ -1229,7 +1229,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) tspring2 = search2->link; if (tspring->ij == tspring2->kl) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 44f524304d2..71b2f6952d5 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -643,12 +643,12 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis { int i; - *collisions = ( CollPair* ) MEM_mallocN ( sizeof ( CollPair ) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision + *collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision *collisions_index = *collisions; for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, - overlap+i, *collisions_index, dt ); + overlap+i, *collisions_index, dt ); } } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 623d4b8a931..674a2d98d07 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1713,7 +1713,7 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si t02 = x1 * x2 + y1 * y2; if (fabs(t02) >= 1.0) - t02 = .5 * M_PI; + t02 = 0.5 * M_PI; else t02 = (saacos(t02)) / 2.0f; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 4aef47159df..4755fccff99 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -186,7 +186,7 @@ DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts) DO_INLINE lfVector *create_lfvector(unsigned int verts) { // TODO: check if memory allocation was successfull */ - return (lfVector *)MEM_callocN (verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); + return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); // return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector)); } /* delete long vector */ @@ -514,7 +514,7 @@ static void print_bfmatrix(fmatrix3x3 *m3) DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs) { // TODO: check if memory allocation was successfull */ - fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN (sizeof (fmatrix3x3) * (verts + springs), "cloth_implicit_alloc_matrix"); + fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN(sizeof(fmatrix3x3) * (verts + springs), "cloth_implicit_alloc_matrix"); temp[0].vcount = verts; temp[0].scount = springs; return temp; @@ -720,7 +720,7 @@ int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd) verts = cloth->verts; // create implicit base - id = (Implicit_Data *)MEM_callocN (sizeof(Implicit_Data), "implicit vecmat"); + id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat"); cloth->implicit = id; /* process diagonal elements */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e3495a15871..d5b1d3c98c8 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -212,7 +212,7 @@ Lattice *BKE_lattice_copy(Lattice *lt) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; - ltn->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + ltn->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(ltn->dvert, lt->dvert, tot); } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index d0b9e73e295..e3b13ca0f17 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -444,7 +444,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) for (i = 0; i < copycount; i++) { if (src[i].dw) { dst[i].dw = MEM_callocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); - memcpy(dst[i].dw, src[i].dw, sizeof (MDeformWeight) * src[i].totweight); + memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight); } } @@ -957,7 +957,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll } final++; - (*alledge) = medge = MEM_callocN(sizeof (MEdge) * final, "BKE_mesh_make_edges mdge"); + (*alledge) = medge = MEM_callocN(sizeof(MEdge) * final, "BKE_mesh_make_edges mdge"); (*_totedge) = final; for (a = totedge, ed = edsort; a > 1; a--, ed++) { diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6c7336958b5..569e69f2d51 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4114,7 +4114,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) if (ptype&readMask) { activeParts++; - gzread(gzf, &(pa->size), sizeof( float )); + gzread(gzf, &(pa->size), sizeof(float)); pa->size /= 10.0f; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ebc31517524..32def1be647 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1856,7 +1856,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM BKE_ptcache_write(&pid, framenr); tend(); - // printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, ( float ) tval() ); + // printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, (float) tval() ); } } diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 9795d4dea2d..ff234a971aa 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -211,7 +211,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t max { size_t len = 0; while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */ - len += BLI_str_utf8_from_unicode(*src++, dst+len); + len += BLI_str_utf8_from_unicode(*src++, dst + len); } dst[len]= '\0'; diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 201417b65d6..d591f98ddc0 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -576,7 +576,7 @@ void *BLI_thread_queue_pop(ThreadQueue *queue) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -642,7 +642,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -678,7 +678,7 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue) /* wait for finish condition */ pthread_mutex_lock(&queue->mutex); - while(!BLI_gsqueue_is_empty(queue->queue)) + while (!BLI_gsqueue_is_empty(queue->queue)) pthread_cond_wait(&queue->finish_cond, &queue->mutex); pthread_mutex_unlock(&queue->mutex); diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 0088d24d741..727e42dc8de 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -49,10 +49,10 @@ enum { typedef struct VoronoiEvent { struct VoronoiEvent *next, *prev; - int type; /* type of event (site or circle) */ - float site[2]; /* site for which event was generated */ + int type; /* type of event (site or circle) */ + float site[2]; /* site for which event was generated */ - struct VoronoiParabola *parabola; /* parabola for which event was generated */ + struct VoronoiParabola *parabola; /* parabola for which event was generated */ } VoronoiEvent; typedef struct VoronoiParabola { @@ -254,9 +254,9 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f b = b1 - b2; c = c1 - c2; - disc = b*b - 4 * a * c; - x1 = (-b + sqrtf(disc)) / (2*a); - x2 = (-b - sqrtf(disc)) / (2*a); + disc = b * b - 4 * a * c; + x1 = (-b + sqrtf(disc)) / (2 * a); + x2 = (-b - sqrtf(disc)) / (2 * a); if (p[1] < r[1]) ry = MAX2(x1, x2); @@ -268,7 +268,7 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f static VoronoiParabola *voronoi_getParabolaByX(VoronoiProcess *process, float xx) { - VoronoiParabola * par = process->root; + VoronoiParabola *par = process->root; float x = 0.0f; float ly = process->current_y; @@ -371,7 +371,7 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2]) s[0] = (site[0] + fp[0]) / 2.0f; s[1] = process->height; - if(site[0] > fp[0]) + if (site[0] > fp[0]) root->edge = voronoiEdge_new(s, fp, site); else root->edge = voronoiEdge_new(s, site, fp); @@ -506,12 +506,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) { const float corners[4][2] = {{0.0f, 0.0f}, - {width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}}; + {width - 1, 0.0f}, + {width - 1, height - 1}, + {0.0f, height - 1}}; int i; - if (IN_RANGE_INCL(coord[0], 0, width-1) && IN_RANGE_INCL(coord[1], 0, height-1)) { + if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) { return; } @@ -609,9 +609,9 @@ static int voronoi_getNextSideCoord(ListBase *edges, float coord[2], int dim, in static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height) { const float corners[4][2] = {{width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}, - {0.0f, 0.0f}}; + {width - 1, height - 1}, + {0.0f, height - 1}, + {0.0f, 0.0f}}; int i, dim = 0, dir = 1; float coord[2] = {0.0f, 0.0f}; @@ -756,7 +756,7 @@ static void voronoi_addTriangle(int v1, int v2, int v3, int (**triangles)[3], in *triangles = MEM_callocN(sizeof(int[3]), "trianglulation triangles"); } - triangle = (int*)&(*triangles)[(*triangles_total)]; + triangle = (int *)&(*triangles)[(*triangles_total)]; triangle[0] = v1; triangle[1] = v2; diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 9582da4fe5c..57829f777c5 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1114,7 +1114,7 @@ bool AnimationExporter::hasAnimations(Scene *sce) { LinkNode *node; - for(node=this->export_settings->export_set; node; node=node->next) { + for (node=this->export_settings->export_set; node; node=node->next) { Object *ob = (Object *)node->link; FCurve *fcu = 0; diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index ef22a76d28e..07e11183dd0 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -49,7 +49,7 @@ void MaterialsExporter::exportMaterials(Scene *sce) bool MaterialsExporter::hasMaterials(Scene *sce) { LinkNode *node; - for(node=this->export_settings->export_set; node; node = node->next) { + for (node=this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *)node->link; int a; for (a = 0; a < ob->totcol; a++) { diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 80396af895d..a410c28f47d 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -231,7 +231,7 @@ void WorkScheduler::initialize() cl_platform_id platform = platforms[indexPlatform]; cl_uint numberOfDevices; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof (cl_device_id), 0); + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof(cl_device_id), 0); numberOfDevicesReceived += numberOfDevices; } if (totalNumberOfDevices > 0) { diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index ba54c8ad9d6..8344a4d248b 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1216,7 +1216,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float gsz = rsize[2]; // by the do_*EdgeDetection() function. fsz = gsz + isz + osz; // calculate size of pixel index buffer needed - gbuf = (unsigned short *)MEM_callocN(sizeof (unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer + gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index a8f8d2974e5..3883dce7671 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -156,7 +156,7 @@ void duplicate_fcurve_keys(FCurve *fcu) memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); - memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof (BezTriple) * (fcu->totvert - (i + 1))); + memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; /* reassign pointers... (free old, and add new) */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 3c802020747..0007facdf8f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -878,7 +878,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), glPopMatrix(); /* min max */ - glColor3f(.5f, .5f, .5f); + glColor3f(0.5f, 0.5f, 0.5f); min = yofs + scopes->minmax[0][0] * h; max = yofs + scopes->minmax[0][1] * h; CLAMP(min, rect.ymin, rect.ymax); @@ -1012,7 +1012,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco int i, j; float w, h, centerx, centery, diam; float alpha; - const float colors[6][3] = {{.75, 0, 0}, {.75, .75, 0}, {0, .75, 0}, {0, .75, .75}, {0, 0, .75}, {.75, 0, .75}}; + const float colors[6][3] = { + {0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0}, + {0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}}; GLint scissor[4]; rect.xmin = (float)recti->xmin + 1; @@ -1375,7 +1377,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } - /* grid, every .25 step */ + /* grid, every 0.25 step */ gl_shaded_color((unsigned char *)wcol->inner, -16); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 385f74acbd2..737c0377f27 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -347,7 +347,7 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a glColor4f(0.0f, 0.0f, 0.0f, 1); viconutil_draw_lineloop_smooth(pts, 3); - glColor3f(.9f, .9f, .9f); + glColor3f(0.9f, 0.9f, 0.9f); viconutil_draw_points(pts, 3, 1); } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 02f34873ea7..fe46a5dc9c5 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -737,7 +737,8 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); - rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw + /* alpha 80 is not meant editable, used for wire+action draw */ + rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 0a9944debe1..e85f47837ef 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -102,7 +102,7 @@ void make_editLatt(Object *obedit) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->editlatt->latt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } @@ -162,7 +162,7 @@ void load_editLatt(Object *obedit) if (editlt->dvert) { tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4e98d2ae967..55fb130e2c0 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1175,7 +1175,7 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sAreaSplitData *sd; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = CTX_wm_area(C); @@ -1210,7 +1210,7 @@ static int area_split_init(bContext *C, wmOperator *op) if (dir == 'h' && sa->winy < 2 * areaminy) return 0; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = sa; @@ -2180,7 +2180,7 @@ static int area_join_init(bContext *C, wmOperator *op) return 0; } - jd = (sAreaJoinData *)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); + jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join"); jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4dee83dbb82..b0867608840 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5096,8 +5096,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* This can be removed once fixed properly in * BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) - * at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available */ - if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) + * at zero pressure we should do nothing 1/2^12 is 0.0002 which is the sensitivity of the most sensitive pen tablet available */ + if (tablet && (pressure < 0.0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) return; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 32e6f588e27..59e47363a22 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -550,7 +550,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) /* fast switch to render slots */ for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) { - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY+i, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot"); RNA_int_set(kmi->ptr, "value", i); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8aa56823baf..4ed9acf1481 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1002,7 +1002,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if (node->flag & (NODE_ACTIVE | SELECT) ) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1105,7 +1105,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* XXX only kept for debugging * selection state is indicated by socket outline below! */ - #if 0 +#if 0 /* body */ uiSetRoundBox(15); UI_ThemeColor4(TH_NODE); @@ -1116,18 +1116,18 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* outline active and selected emphasis */ if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); - glEnable( GL_LINE_SMOOTH ); + glEnable(GL_LINE_SMOOTH); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if( node->flag & NODE_ACTIVE ) + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); else UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); - glDisable( GL_LINE_SMOOTH ); + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - #endif +#endif /* only draw input socket. as they all are placed on the same position. * highlight also if node itself is selected, since we don't display the node body separately! @@ -1194,7 +1194,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap uiLayout *col; int source; - if(!imaptr->data) + if (!imaptr->data) return; col = uiLayoutColumn(layout, 0); @@ -2429,7 +2429,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL); - uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 463a262c09c..8be5b644afb 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -825,7 +825,7 @@ typedef struct DrawCache { static void text_drawcache_init(SpaceText *st) { - DrawCache *drawcache = MEM_callocN(sizeof (DrawCache), "text draw cache"); + DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache"); drawcache->winx = -1; drawcache->nlines = BLI_countlist(&st->text->lines); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 43252111303..7d39a89a130 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -431,7 +431,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r } tend(); - // printf ( "Draw Time: %f\n",( float ) tval() ); + // printf ( "Draw Time: %f\n",(float) tval() ); if (tex_shadow) GPU_texture_unbind(tex_shadow); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d632314f3ca..cc3d2d383b8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1669,7 +1669,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom = RV3D_CAMZOOM_MAX; } else if (rv3d->dist > 0.001f * v3d->grid) { - view_zoom_mouseloc(ar, .83333f, mx, my); + view_zoom_mouseloc(ar, 0.83333f, mx, my); } } @@ -1921,7 +1921,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 1.2f); } else { - view_dolly_mouseloc(ar, rv3d->ofs, mousevec, .83333f); + view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 0.83333f); } if (rv3d->viewlock & RV3D_BOXVIEW) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9ebd43cd0d1..90b67951614 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -221,7 +221,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) setlinestyle(0); cpack(0x0); fdrawline(-0.020 / w, 0, -0.1 / w, 0); - fdrawline(0.1 / w, 0, .020 / w, 0); + fdrawline(0.1 / w, 0, 0.020 / w, 0); fdrawline(0, -0.020 / h, 0, -0.1 / h); fdrawline(0, 0.1 / h, 0, 0.020 / h); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a1bd8dcb3a3..e718a486561 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -246,7 +246,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap){ /* only actually enable if it's supported */ GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object; - if(old_value != GTS.gpu_mipmap) { + if (old_value != GTS.gpu_mipmap) { GPU_free_images(); } } @@ -644,7 +644,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } else { - if(GTS.gpu_mipmap) { + if (GTS.gpu_mipmap) { if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 62c3051727d..20f58f4d16e 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -161,11 +161,11 @@ DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIE DefNode( CompositorNode, CMP_NODE_TRANSFORM, dev_cmd_transform, "TRANSFORM", Transform, "Transform", "" ) DefNode( CompositorNode, CMP_NODE_STABILIZE2D, def_cmp_stabilize2d, "STABILIZE2D", Stabilize, "Stabilize 2D", "" ) DefNode( CompositorNode, CMP_NODE_MOVIEDISTORTION,def_cmp_moviedistortion,"MOVIEDISTORTION",MovieDistortion, "Movie Distortion", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK" ,BoxMask, "Box mask", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK" ,EllipseMask, "Ellipse mask", "" ) -DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE" ,BokehImage, "Bokeh image", "" ) -DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEHBLUR" ,BokehBlur, "Bokeh Blur", "" ) -DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH" ,Switch, "Switch", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK", BoxMask, "Box mask", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK", EllipseMask, "Ellipse mask", "" ) +DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE", BokehImage, "Bokeh image", "" ) +DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEHBLUR", BokehBlur, "Bokeh Blur", "" ) +DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH", Switch, "Switch", "" ) DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "ColorCorrection", "" ) DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK", Mask, "Mask", "" ) DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" ) diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index c0efff2d179..4224b3936c6 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -117,18 +117,18 @@ static int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[RNA_ { SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; - if (settings->fluid) - { + if (settings->fluid) { float *density = smoke_get_density(settings->fluid); unsigned int size = settings->res[0] * settings->res[1] * settings->res[2]; - if(density) + if (density) length[0] = size; else length[0] = 0; } - else - length[0] = 0; // No smoke domain created yet + else { + length[0] = 0; /* No smoke domain created yet */ + } return length[0]; } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 85dee2617d8..801bec30ecf 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -780,21 +780,21 @@ static void rna_def_trackingCamera(BlenderRNA *brna) prop = RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k1"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K1", "First coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); prop = RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k2"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K2", "Second coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); prop = RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k3"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K3", "Third coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index d323839e690..91c3e9fbaf7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -72,7 +72,7 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** BKE_mask_rasterize(mask, sx, sy, res, TRUE, node->custom1); - if(node->custom1){ + if (node->custom1) { PLX_antialias_buffer(res,sx,sy); } /* pass on output and free */ diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c index 6456742e22b..beefc0b6eae 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -36,13 +36,13 @@ static bNodeSocketTemplate outputs[] = { /* node type definition */ void register_node_type_sh_particle_info(bNodeTreeType *ttype) { - static bNodeType ntype; + static bNodeType ntype; - node_type_base(ttype, &ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, NULL, outputs); - node_type_size(&ntype, 150, 60, 200); + node_type_base(ttype, &ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, NULL, outputs); + node_type_size(&ntype, 150, 60, 200); - nodeRegisterType(ttype, &ntype); + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 255ed9e51fc..28d03db1687 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -88,9 +88,9 @@ void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) } if (in->hasoutput && in->sockettype == SOCK_VECTOR) { - out[0] = out[0] * .5f + .5f; - out[1] = out[1] * .5f + .5f; - out[2] = out[2] * .5f + .5f; + out[0] = out[0] * 0.5f + 0.5f; + out[1] = out[1] * 0.5f + 0.5f; + out[2] = out[2] * 0.5f + 0.5f; out[3] = 1; } } diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c index ded3afe4c6b..2add5c820eb 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ b/source/blender/nodes/texture/nodes/node_texture_coord.c @@ -40,9 +40,7 @@ static bNodeSocketTemplate outputs[]= { static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread)) { - out[0] = p->co[0]; - out[1] = p->co[1]; - out[2] = p->co[2]; + copy_v3_v3(out, p->co); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 52455e024b4..6863eab9150 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -80,7 +80,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor float col[4]; tex_input_rgba(col, in[4], p, thread); - hue += 0.5f; /* [-.5, .5] -> [0, 1] */ + hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */ do_hue_sat_fac(node, out, hue, sat, val, col, fac); diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 0d985273eda..98382e24290 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -65,7 +65,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor if (node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ - copy_v4_v4(out, (fabs(co[0] - co[1]) < .01) ? white : red); + copy_v4_v4(out, (fabs(co[0] - co[1]) < 0.01) ? white : red); } else if (nodetex) { TexResult texres; diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 54044b62e04..8fb3a3f74d6 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1874,7 +1874,7 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa { VectorObject *vecA = NULL, *vecB = NULL; int result = 0; - double epsilon = .000001f; + double epsilon = 0.000001f; double lenA, lenB; if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)) { diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index e4c4e905aa6..c1f85914479 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -376,7 +376,7 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 return normalize * 1.f; } else { /* schlick */ - const float k = 1.55f * g - .55f * g * g * g; + const float k = 1.55f * g - 0.55f * g * g * g; const float kcostheta = k * dot_v3v3(w, wp); return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } @@ -394,7 +394,7 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f); case MA_VOL_PH_SCHLICK: { - const float k = 1.55f * g - .55f * g * g * g; + const float k = 1.55f * g - 0.55f * g * g * g; const float kcostheta = k * costheta; return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index ecde9bb2de8..c88858c44da 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2858,7 +2858,7 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata) p1[0]= v1[0]; p1[1]= v1[1]; - /* official formula 2*p2 - .5*p1 - .5*p3 */ + /* official formula 2*p2 - 0.5*p1 - 0.5*p3 */ p2[0]= -0.5f*p1[0] - 0.5f*p3[0]; p2[1]= -0.5f*p1[1] - 0.5f*p3[1]; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 696def2cebe..770d621f2b5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2295,8 +2295,8 @@ static void WM_OT_collada_export(wmOperatorType *ot) RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); - RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, - 0, "Resolution", "Modifier resolution for export"); + RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, 0, + "Resolution", "Modifier resolution for export"); RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", "Export only selected elements"); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 265a3c11377..6b3735020b4 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -369,7 +369,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice grey */ - glClearColor(.55, .55, .55, 0.0); + glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); @@ -987,7 +987,7 @@ void wm_window_testbreak(void) /* only check for breaks every 50 milliseconds * if we get called more often. */ - if ((curtime - ltime) > .05) { + if ((curtime - ltime) > 0.05) { int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ if (hasevent) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 927a0535870..3c9ca77b37e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -446,8 +446,8 @@ static void GetRGB(short type, c2 = KX_Mcol2uint_new(mmcol[2]); if (mface->v4) c3 = KX_Mcol2uint_new(mmcol[3]); - }else // backup white - { + } + else { // backup white c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); c2 = KX_rgbaint2uint_new(color); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 07680297b7d..28e34769ab8 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -860,7 +860,7 @@ void BL_ConvertActuators(const char* maggiename, float paraArg1 = 0.0; float paraArg2 = 0.0; - switch (randAct->distribution) { + switch (randAct->distribution) { case ACT_RANDOM_BOOL_CONST: modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST; paraArg1 = (float) randAct->int_arg_1; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index c50e42446a5..124a8e28f57 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -588,7 +588,7 @@ public: /* These static functions are referenced by ALL PyObjectPlus_Proxy types * they take the C++ reference from the PyObjectPlus_Proxy and call - * its own virtual py_repr, py_base_dealloc ,etc. functions. + * its own virtual py_repr, py_base_dealloc, etc. functions. */ static PyObject* py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */ diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 9a23244fa96..b505353c7cd 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -94,7 +94,7 @@ public: void InsertActiveQList(SG_QList& head) { SG_QList::iterator<SCA_ILogicBrick> it(head); - for(it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + for (it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); it.add_back(this); } @@ -119,9 +119,8 @@ public: // this element comes before the first *current = this; } - else - { - for(++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + else { + for (++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); } it.add_back(this); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index c82e015919d..2c6beb79fd3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -191,7 +191,8 @@ bool SCA_JoystickSensor::Evaluate() if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; result = true; - }else { + } + else { if (m_istrig) { m_istrig = 0; result = true; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 98854115d0a..c0fca88c426 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -835,12 +835,12 @@ KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" ) return PyLong_FromSsize_t( ( mShader !=0 && mOk ) ); } -KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg ,"getVertexProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg, "getVertexProg( )" ) { return PyUnicode_FromString(vertProg?vertProg:""); } -KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg, "getFragmentProg( )" ) { return PyUnicode_FromString(fragProg?fragProg:""); } @@ -941,7 +941,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f, "setUniform2f(name, fx, fy)") { if (mError) { Py_RETURN_NONE; @@ -1038,7 +1038,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i, "setUniform2i(name, ix, iy)") { if (mError) { Py_RETURN_NONE; @@ -1109,7 +1109,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " return NULL; } -KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )") +KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list3 or list4) )") { if (mError) { Py_RETURN_NONE; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 5459ebe945c..79e6c35e6a2 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -899,8 +899,8 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") mMaterial->SetSharedMaterial(true); mScene->GetBucketManager()->ReleaseDisplayLists(this); return mShader->GetProxy(); - }else - { + } + else { // decref all references to the object // then delete it! // We will then go back to fixed functionality diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 3b3a1f5cbfb..5fcd591d822 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -12,7 +12,7 @@ #include "CcdPhysicsController.h" #endif -class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController +class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController { private: int m_savedCollisionFlags; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 6d57b6950f1..f149b676aa5 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -105,7 +105,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -140,7 +141,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -595,7 +597,7 @@ void KX_Dome::CreateMeshDome180(void) /* Left face - two triangles */ cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[0][1] = .0; + cubeleft[0].verts[0][1] = 0.0; cubeleft[0].verts[0][2] = -0.5; cubeleft[0].u[0] = 0.0; cubeleft[0].v[0] = 0.0; @@ -1547,7 +1549,7 @@ void KX_Dome::CalculateCameraOrientation() m_locRot[1] = MT_Matrix3x3( // Bottom c, s, 0.0, - 0.0 ,0.0, 1.0, + 0.0, 0.0, 1.0, s, -c, 0.0); m_locRot[2] = MT_Matrix3x3( // 45deg - Left diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 836005cf25e..04113607531 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1472,18 +1472,18 @@ void KX_KetsjiEngine::RenderDebugProperties() for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord,ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); double time = m_logger->GetAverage((KX_TimeCategory)j); debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord + 60 ,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + 60, ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); ycoord += 14; } } diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index b0000405893..8924567acde 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -104,19 +104,20 @@ bool PyMatTo(PyObject* pymat, T& mat) if (!PyErr_Occurred() && PySequence_Check(pyrow)) { unsigned int cols = PySequence_Size(pyrow); - if (cols != Size(mat)) + if (cols != Size(mat)) { noerror = false; - else - { - for(unsigned int col = 0; col < cols; col++) - { + } + else { + for (unsigned int col = 0; col < cols; col++) { PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */ mat[row][col] = PyFloat_AsDouble(item); Py_DECREF(item); } } - } else + } + else { noerror = false; + } Py_DECREF(pyrow); } } else diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 978944c20e8..74009f51078 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -104,42 +104,42 @@ void KX_RadarSensor::SynchronizeTransform() { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; default: @@ -154,7 +154,7 @@ void KX_RadarSensor::SynchronizeTransform() m_cone_origin[1] = temp[1]; m_cone_origin[2] = temp[2]; - temp = trans(MT_Point3(0, -m_coneheight/2.0 ,0)); + temp = trans(MT_Point3(0, -m_coneheight/2.0, 0)); m_cone_target[0] = temp[0]; m_cone_target[1] = temp[1]; m_cone_target[2] = temp[2]; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index cd6bb5a1cbc..39b7c44eda9 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -258,7 +258,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject() // Now it needs to be added to the current scene. SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); - game_obj->setLinearVelocity(m_linear_velocity ,m_localLinvFlag); + game_obj->setLinearVelocity(m_linear_velocity, m_localLinvFlag); game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag); game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 343cb549337..47cd4ff8da5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1811,8 +1811,8 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); - }else - { + } + else { btDbvt::collideKDOP(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,nplanes,dispatcher); btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher); } |