/** * Removes a thing from the container. * @param child The thing to be contained. */ void Container::removeChild(Contained* child) { DEBUG_M("Entering function removeChild..."); if(!child) { return; } DEBUG_H("\tRemoving object from container object vector."); ChildrenIterator found = find(getChildBegin(), getChildEnd(), child); //while((found = find(getChildBegin(), getChildEnd(), child)) != getChildEnd()) { if(found != getChildEnd()) { //Object* object = dynamic_cast<Object*>(*found); if(*found && ((*found) == child)) { //DEBUG_H("\t\tFound '%s'... Removing...", object->getTag().c_str()); children_.erase(found); } } //} DEBUG_H("\tRemoving object from container tag list."); ChildrenTagIterator iter = tags_.begin(); while(iter != tags_.end()) { Contained* contained = dynamic_cast<Object*>(iter->second); if(contained && contained == child) { //DEBUG_H("\t\tFound '%s'... Removing...", object->getTag().c_str()); tags_.erase(iter); iter = tags_.begin(); } else { iter++; } } DEBUG_H("\tExiting function..."); #warning ['TODO']: This... }
/** * ModelTempory deconstructor. * @param the ModelTempory to free. * @see ModelTempory * @see ModelTempory_ModelTempory() * \memberof ModelTempory */ void ModelTempory_0ModelTempory(ModelTempory* tempory) { DEBUG_M("Entering function..."); DEBUG_H("\tDeleting sinks..."); Hookup_Debug(tempory->sinks); List_DeleteData(tempory->sinks); DELETE(tempory->sinks); DEBUG_H("\tDeleting sources..."); List_DeleteData(tempory->sources); DELETE(tempory->sources); DEBUG_H("\tDeleting unsorted..."); List_DeleteData(tempory->unsorted); DELETE(tempory->unsorted); DEBUG_H("\tDeleting deleteme..."); List_DeleteData(tempory->deleteme); DELETE(tempory->deleteme); DEBUG_H("\tfreeing freeme..."); List_FreeData(tempory->freeme); DELETE(tempory->freeme); /*DEBUG_H("\tDeleting image_sources..."); List_DeleteData(tempory->image_sources); DELETE(tempory->image_sources);*/ free(tempory); }
/** * Adds a thing to the container. * @param child The thing to be contained. */ void Container::addChild(Contained* child) { DEBUG_M("Entering function addChild..."); if(!child) { DEBUG_H("\tNo child..."); return; } // Stop adding the child more than once ChildrenIterator found = find(getChildBegin(), getChildEnd(), child); if(found != getChildEnd()) { DEBUG_H("\tChild alread in list..."); return; } DEBUG_H("Child adding to list..."); child->setParent(this); children_.push_back(child); //DEBUG_H("Child adding to list..."); Tagged* tagged = dynamic_cast<Tagged*>(child); if(!tagged) { return; } tags_.insert(ChildrenTagPair(tagged->getTag(), tagged)); }
/** * Image Constructor. * \memberof Image */ Image* Image_Image(char* filename) { DEBUG_M("Entering function..."); DEBUG_H("Getting filename length..."); int filename_size = sizeof(char) * strlen(filename) + 1; DEBUG_H("Size(%d) mallocing Image", filename_size); Image* image = malloc(sizeof(Image)); image->class_ = &Image_c; image->filename = malloc(filename_size); image->id = 0; strncpy(image->filename, filename, filename_size); DEBUG_H("Finished... created %p", image); return image; }
/** * A debuging function. * @param The array to dump. * \memberof FloatArray */ void FloatArray_Dump(FloatArray* array) { int i; DEBUG_H("Float array dumping %d values\n", array->count); for(i = 0; i < array->count; i++) { printf("%f, ", array->values[i]); } printf("\n"); }
/** * SceneNode deconstructor. * @param node The node to free. * \memberof SceneNode */ void SceneNode_0SceneNode(SceneNode *node) { DEBUG_M("Entering function..."); assert(node); #warning ['TODO']: Free SceneNode memory recusivly, right now it leaks... DEBUG_H("Deleting mesh..."); DELETE(node->mesh); node->mesh = NULL; DEBUG_H("Deleting Child node..."); DELETE(node->child); DEBUG_H("Deleting next node..."); DELETE(node->next); DEBUG_H("Deleting rotations..."); List_DeleteData(node->rotations); DELETE(node->rotations); node->rotations = NULL; DEBUG_H("Deleting self..."); free(node); }
void RigidBody::loadShapeFromModel_ProcessNode_(SceneNode* node, btCompoundShape* combined) { DEBUG_M("Entering function..."); Mesh* mesh = node->mesh; if(!mesh) { return; } Triangles* triangles = mesh->triangles; if(!triangles) { return; } FloatArray* vertices = triangles->vertices; if(!vertices) { return; } /*btBvhTriangleMeshShape* meshShape btTriangleIndexVertexArray* meshInterface = new btTriangleIndexVertexArray();*/ /*btTriangleMesh* triangleMesh = new btTriangleMesh(); for(int i = 0; i < vertices->count; i+=3) { btVector3* vertex = new btVector3(vertices->values[i], vertices->values[i+1], vertices->values[i+2]); triangleMesh->addTriangle(vertex, true); }*/ DEBUG_H("\tFlag..."); #warning ['TODO']: Change from malloc to triBase = new int[count] // We need to make a fake index since the vertex data isn't indexed but its required by bullet int* triangleIndexBase = (int*)malloc(vertices->count * sizeof(int)); for(int i = 0; i < vertices->count; i++) { triangleIndexBase[i] = i; } DEBUG_H("\tFlag..."); int numTriangles = vertices->count / 3; int triangleIndexStride = sizeof(int) * 3; int vertexStride = sizeof(float) * 3; DEBUG_H("\tFlag..."); btTriangleIndexVertexArray* triArray = new btTriangleIndexVertexArray( numTriangles, triangleIndexBase, triangleIndexStride, vertices->count, vertices->values, vertexStride ); DEBUG_H("\tFlag..."); // Turn triangles into a mesh... // Offset the mesh position... // Add mesh to combined object... float x = node->translate[0]; float y = node->translate[1]; float z = node->translate[2]; DEBUG_H("\tFlag..."); //float rx = mesh->rotations btQuaternion rot(0, 1, 0, 0); ListNode* rot_node = node->rotations->first; while(rot_node) { DEBUG_H("\t\tlooping node..."); Rotate* rotate = (Rotate*)rot_node->data; if(rotate) { DEBUG_H("\t\t\trotate..."); float rx = rotate->x; float ry = rotate->y; float rz = rotate->z; float ra = rotate->angle; //btQuaternion addRotation(btVector3(rx, ry, rz), ra); //rotation = rotation + addRotation; //rotation += addRotation;//btQuaternion(btVector3(rx, ry, rz), ra); //rotation.operator+=(addRotation); rot += btQuaternion(btVector3(rx, ry, rz), ra); } DEBUG_H("\tnext..."); rot_node = rot_node->next; } DEBUG_H("\tmake mesh..."); //btTransform* transform = new btTransform(rot, btVector3(x, y, z)); btBvhTriangleMeshShape* trimeshShape = new btBvhTriangleMeshShape(triArray, true); DEBUG_H("\ttest..."); combined->addChildShape(btTransform(rot, btVector3(x, y, z)), trimeshShape); //free(indices); #warning ['TODO']: Free indices DEBUG_H("\texiting function..."); }
// // Call at 1ms ISR - Part of ISR // ISR complete within 5uS // void my_TMR_ISR(void) { unsigned char tFS=0; static u32 tPACC=0; static unsigned char tLED=0; static unsigned int tTMR=0; #ifdef debug_isr DEBUG_H(); #endif tTMR++; if (tTMR>=200) { // Generate Sync. Task Flag on Every 100mS // Decouple it from ISR mTask_Sync_Flag = 1; mTMR_100ms +=2; tTMR = 0; } // Phase Accumulator to generate Flow Sensor count // 60000 phase unit per cycle // n delta phase unit = n count / min // 1 delta phase unit = 1 count / min // 3000 delta phase unit = 3000 counts / min mDP = mFR; tPACC += mDP; if (tPACC>=60000) { tPACC = 0; } if (tPACC<30000) { FS_O = 1; } else { FS_O = 0; } // Flow Sensor Input 0 tFS = FS_I0; if ((tFS != mFS_CNT[0][1]) && (tFS==1)) mFS_CNT[0][0]++; mFS_CNT[0][1] = tFS; // Flow Sensor Input 1 tFS = FS_I1; if ((tFS != mFS_CNT[1][1]) && (tFS==1)) mFS_CNT[1][0]++; mFS_CNT[1][1] = tFS; // Flow Sensor Input 2 tFS = FS_I2; if ((tFS != mFS_CNT[2][1]) && (tFS==1)) mFS_CNT[2][0]++; mFS_CNT[2][1] = tFS; tLED ++; if (tLED>=16) { tLED = 0; } if (mLED[0]>tLED) { LED_R_ON(); } else { LED_R_OFF(); } my_printQ(); #ifdef debug_isr DEBUG_L(); #endif }
/** * Sets the size of the area. * @param width The width. * @param height The heigh. */ void Area::setSize(int width, int height) { DEBUG_M("Entering function..."); int old_width = width_; int old_height = height_; #warning ['TODO']: Decide when tiles are unloaded DEBUG_H("\tUnloading dropped tiles..."); // Unload any tiles that are dropped if(width < old_width) { DEBUG_H("\tWidth is less than old width, scrubbing lost tiles..."); for(int y = 0; y < height; y++) { for(int x = old_width; x < width; x++) { delete getTile(x, y); setSolid(x, y, false); } } } if(height < old_height) { DEBUG_H("\tHeight is less than old width, scrubbing lost tiles..."); for(int y = old_height; y < height; y++) { for(int x = 0; x < old_width; x++) { delete getTile(x, y); setSolid(x, y, false); } } } width_ = width; height_ = height; DEBUG_H("\tRealPosition tile space..."); tiles_ = (Tile***)regrowArray_((void***)tiles_, old_width, old_height, width, height); DEBUG_H("\tRealPosition blocker space..."); walkblockers_ = (RigidBody***)regrowArray_((void***)walkblockers_, old_width, old_height, width, height); DEBUG_H("\tAllocated..."); // If we are freeing the Area if(!width || !height) { return; } if(!tiles_) { ERROR("Failed to allocate memory for tile map."); return; } #warning ['TODO']: This function should be split up some more, also shouldn't need to NULL tiles befoure setting them. // Set new tiles to default if(width > old_width) { DEBUG_H("\tWidth is > than old width, making new tiles..."); for(int y = 0; y < height; y++) { for(int x = old_width; x < width; x++) { DEBUG_H("\t\tsetting %dx%d...", x, y); tiles_[x][y] = NULL; walkblockers_[x][y] = NULL; } } } if(height > old_height) { DEBUG_H("\theight is > than old height, making new tiles..."); for(int y = old_height; y < height; y++) { for(int x = 0; x < width; x++) { DEBUG_H("\t\tsetting %dx%d...", x, y); tiles_[x][y] = NULL; walkblockers_[x][y] = NULL; } } } float x_offset = (old_width - width_) * (TILEWIDTH / 2.0f); float z_offset = (old_height - height_) * (TILEWIDTH / 2.0f); for(ChildrenIterator iter = getChildBegin(); iter != getChildEnd(); iter++) { Object* object = dynamic_cast<Object*>(*iter); if(!object) { continue; } object->setX(object->getX() - x_offset); object->setZ(object->getZ() - z_offset); } DEBUG_H("\tFunction finished, area now %d, %d...", getWidth(), getHeight()); }