void World::build(void) { int num_samples = 16; vp.set_hres(400); vp.set_vres(400); vp.set_samples(num_samples); tracer_ptr = new RayCast(this); Pinhole* pinhole_ptr = new Pinhole; pinhole_ptr->set_eye(100, 0, 100); pinhole_ptr->set_lookat(0, 1, 0); pinhole_ptr->set_view_distance(8000); pinhole_ptr->compute_uvw(); set_camera(pinhole_ptr); PointLight* light_ptr = new PointLight; light_ptr->set_location(50, 50, 1); light_ptr->scale_radiance(3.0); add_light(light_ptr); Phong* phong_ptr = new Phong; phong_ptr->set_ka(0.25); phong_ptr->set_kd(0.8); phong_ptr->set_cd(0.75); phong_ptr->set_ks(0.15); phong_ptr->set_exp(50.0); Sphere* sphere_ptr = new Sphere; sphere_ptr->set_material(phong_ptr); add_object(sphere_ptr); }
static int open_files(void) { unsigned int i, nr_to_open; generate_filelist(); if (files_in_index == 0) { /* Something bad happened. Crappy -V maybe? */ panic(EXIT_NO_FILES); return FALSE; } nr_to_open = min(files_in_index, NR_FILE_FDS); if (fileindex == NULL) /* this can happen if we ctrl-c'd */ return FALSE; for (i = 0; i < nr_to_open; i++) { struct object *obj; int fd; fd = open_file(); obj = alloc_object(); obj->filefd = fd; add_object(obj, OBJ_GLOBAL, OBJ_FD_FILE); } return TRUE; }
static int __i915_gem_userptr_set_active(struct drm_i915_gem_object *obj, bool value) { int ret = 0; /* During mm_invalidate_range we need to cancel any userptr that * overlaps the range being invalidated. Doing so requires the * struct_mutex, and that risks recursion. In order to cause * recursion, the user must alias the userptr address space with * a GTT mmapping (possible with a MAP_FIXED) - then when we have * to invalidate that mmaping, mm_invalidate_range is called with * the userptr address *and* the struct_mutex held. To prevent that * we set a flag under the i915_mmu_notifier spinlock to indicate * whether this object is valid. */ #if defined(CONFIG_MMU_NOTIFIER) if (obj->userptr.mmu_object == NULL) return 0; spin_lock(&obj->userptr.mmu_object->mn->lock); /* In order to serialise get_pages with an outstanding * cancel_userptr, we must drop the struct_mutex and try again. */ if (!value) del_object(obj->userptr.mmu_object); else if (!work_pending(&obj->userptr.mmu_object->work)) add_object(obj->userptr.mmu_object); else ret = -EAGAIN; spin_unlock(&obj->userptr.mmu_object->mn->lock); #endif return ret; }
void SVSScene::clear_objects() { objects.clear(); float scale = SVSObject::global_scale; add_object("world", "", std::vector<Zeni::Point3f>(), Zeni::Point3f(), Zeni::Quaternion(), Zeni::Point3f(scale,scale,scale)); }
world::world(const variant& node) : view_distance_(node["view_distance"].as_int(default_view_distance)), seed_(node["seed"].as_int(0)) { ASSERT_LOG(node.has_key("shader"), "Must have 'shader' attribute"); ASSERT_LOG(node["shader"].is_string(), "'shader' attribute must be a string"); shader_ = gles2::shader_program::get_global(node["shader"].as_string())->shader(); if(node.has_key("lighting")) { lighting_.reset(new graphics::lighting(shader_, node["lighting"])); } if(node.has_key("objects")) { for(int n = 0; n != node["objects"].num_elements(); ++n) { add_object(new user_voxel_object(node["objects"][n])); } } if(node.has_key("skybox")) { skybox_.reset(new graphics::skybox(node["skybox"])); } if(node.has_key("chunks")) { logic_.reset(new logical_world(node)); build_fixed(node["chunks"]); } else { build_infinite(); } }
int along (struct edge *edg, double axis[3]) { int orn, k, sgn; double dt; double vect[3]; struct vertex *vtx1, *vtx2; struct arc *a; struct cept *ex; a = edg -> arcptr; vtx1 = a -> vtx[0]; vtx2 = a -> vtx[1]; if (vtx1 == NULL || vtx2 == NULL) { ex = new_cept (PARAMETER_ERROR, NULL_VALUE, FATAL_SEVERITY); add_object (ex, VERTEX, "vtx1 or vtx2"); add_function (ex, "along"); add_source (ex, "msrender.c"); return(0); } orn = edg -> orn; sgn = 1 - 2 * orn; for (k = 0; k < 3; k++) vect[k] = vtx2 -> center[k] - vtx1 -> center[k]; dt = dot_product (vect, axis) * sgn; return (dt > 0.0); }
/* Create an instance of a floating point number */ void add_float(interp_core_type *interp, char *str) { object_type *obj=0; char *c=str; /* check for / */ while(*c!=0 && *c!='/') { c++; } obj=alloc_object(interp, FLOATNUM); /* if we found a / then do the division otherwise we convert it as any other real */ if(*c=='/') { long double x,y; x=strtold(str,0); c++; y=strtold(c,0); /* check for div by 0 */ if(y==0.0) { interp->error=1; obj->value.float_val=0; } else { obj->value.float_val=x/y; } } else { obj->value.float_val=strtold(str, 0); } add_object(interp, obj); }
/* * Set up a childs local mapping list. * A child inherits the initial mappings, and will add to them * when it successfully completes mmap() calls. */ void init_child_mappings(void) { struct list_head *globallist, *node; struct objhead *head; head = get_objhead(OBJ_LOCAL, OBJ_MMAP_ANON); head->destroy = &map_destructor; head->dump = &map_dump; globallist = shm->global_objects[OBJ_MMAP_ANON].list; /* Copy the initial mapping list to the child. * Note we're only copying pointers here, the actual mmaps * will be faulted into the child when they get accessed. */ list_for_each(node, globallist) { struct map *m; struct object *globalobj, *newobj; globalobj = (struct object *) node; m = &globalobj->map; newobj = alloc_object(); newobj->map.ptr = m->ptr; newobj->map.name = strdup(m->name); newobj->map.size = m->size; newobj->map.prot = m->prot; /* We leave type as 'INITIAL' until we change the mapping * by mprotect/mremap/munmap etc.. */ newobj->map.type = INITIAL_ANON; add_object(newobj, OBJ_LOCAL, OBJ_MMAP_ANON); } }
int real_space::object_setting_address(virtual_object *object) { DEBUG(5) dprintf("real_space::object_setting_address() called. this=%p, object=%p\n", this, object); // Default, just add the object return add_object(object); }
void QuadTree::update_object(GameObject *object) { QuadTreeNode *node = m_object_node_map[object->getID()]; node->remove_object(object); add_object(object); }
static int open_fanotify_fds(void) { struct objhead *head; unsigned int i; head = get_objhead(OBJ_GLOBAL, OBJ_FD_FANOTIFY); head->destroy = &fanotifyfd_destructor; for (i = 0; i < NR_INOTIFYFDS; i++) { struct object *obj; unsigned long flags, eventflags; int fd; eventflags = get_fanotify_init_event_flags(); flags = get_fanotify_init_flags(); fd = fanotify_init(flags, eventflags); if (fd < 0) continue; obj = alloc_object(); obj->fanotifyfd = fd; add_object(obj, OBJ_GLOBAL, OBJ_FD_FANOTIFY); output(2, "fd[%d] = fanotify_init(%lx, %lx)\n", fd, flags, eventflags); } //FIXME: right now, returning FALSE means "abort everything", not // "skip this provider", so on -ENOSYS, we have to still register. return TRUE; }
/* do not call undo push in this function (users of this function have to) */ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob; /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ ob= add_object(scene, type); BASACT->lay = ob->lay = layer; /* editor level activate, notifiers */ ED_base_object_activate(C, BASACT); /* more editor stuff */ ED_object_base_init_transform(C, BASACT, loc, rot); DAG_scene_sort(bmain, scene); ED_render_id_flush_update(bmain, ob->data); if(enter_editmode) ED_object_enter_editmode(C, EM_IGNORE_LAYER); WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); return ob; }
bool add(const TObject& object, TFunc&& func) { assert(!m_init_phase && "Call MembersDatabase::prepare_for_lookup() before calling add()."); auto range = find(object.id()); if (range.empty()) { // No relation needs this object. return false; } // At least one relation needs this object. Store it and // "tell" all relations. add_object(object, range); for (auto& elem : range) { assert(!elem.is_removed()); assert(elem.member_id == object.id()); auto rel_handle = m_relations_db[elem.relation_pos]; assert(elem.member_num < rel_handle->members().size()); rel_handle.decrement_members(); if (rel_handle.has_all_members()) { func(rel_handle); } } return true; }
static void __i915_gem_userptr_set_active(struct drm_i915_gem_object *obj, bool value) { struct i915_mmu_object *mo = obj->userptr.mmu_object; /* * During mm_invalidate_range we need to cancel any userptr that * overlaps the range being invalidated. Doing so requires the * struct_mutex, and that risks recursion. In order to cause * recursion, the user must alias the userptr address space with * a GTT mmapping (possible with a MAP_FIXED) - then when we have * to invalidate that mmaping, mm_invalidate_range is called with * the userptr address *and* the struct_mutex held. To prevent that * we set a flag under the i915_mmu_notifier spinlock to indicate * whether this object is valid. */ if (!mo) return; spin_lock(&mo->mn->lock); if (value) add_object(mo); else del_object(mo); spin_unlock(&mo->mn->lock); }
static object* fake_object(const char* reason) { object* obj = object_new(); if (obj == 0) { #ifdef SCRIPT_DEBUG printf("object_new failed during fake for %s\n", reason); #endif free(obj); return 0; } if (add_child(object_root, obj)) { #ifdef SCRIPT_DEBUG printf("add_child failed during fake for %s\n", reason); #endif free(obj); return 0; } obj->name = reason; if (add_object(obj)) { #ifdef SCRIPT_DEBUG printf("add_object failed during fake for %s\n", reason); #endif /*FIXME: clean up parent*/ return 0; } return obj; }
/* * Write the encoding of the byte(s) */ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const std::string& rep_str) { const uint8_t* rep = cast_char_ptr_to_uint8(rep_str.data()); const size_t rep_len = rep_str.size(); return add_object(type_tag, class_tag, rep, rep_len); }
void test_physics(){ printf("testing physics\n"); world_handle hello_world = new_world(); //tests movement, set/get velocity, set/get location(position) po_vector center; center.x = 1.0; center.y = 1.0; po_circle circle2 = create_circ(center, 1.0); po_geometry geo_circle2 = create_geom_circ(circle2, 1.0); po_handle circle02 = add_object (hello_world, &geo_circle2, 20.0, 1.0, 0.0); po_vector location = get_position(circle02); center.x = 0.0; center.y = 0.0; po_circle circle1 = create_circ(center, 5.0); po_geometry geo_circle1 = create_geom_circ(circle1, 1.0); po_handle circle01 = add_object (hello_world, &geo_circle1, 50.0, 0.0, 0.0); set_velocity(circle02,-1.0,0.0); po_vector velocity = get_velocity(circle02); update(hello_world,3); po_vector pos02 = get_position(circle02); po_vector pos01 = get_position(circle01); assert(pos02.x == 17.0); assert(pos02.y == 1.0); assert(pos01.x == 50.0); assert(pos01.y == 0.0); set_location(circle01, 0.0, 0.0); set_velocity(circle01, -7.76,1.7); set_location(circle02, 20.0, 0.0); set_velocity(circle02, -9.0,2.0); update(hello_world,1); po_vector pos002 = get_position(circle02); po_vector pos001 = get_position(circle01); assert( pos002.x == 11.0); assert( pos002.y == 2.0); assert(fabs(pos001.x - -7.76) <= EPSILON); assert(fabs(pos001.y - 1.7)<= EPSILON); }
void Ekiga::ChatCore::add_dialect (DialectPtr dialect) { add_object (dialect); dialect->updated.connect (boost::ref (updated)); dialect->questions.connect (boost::ref (questions)); dialect_added (dialect); }
/* Create a number */ void add_number(interp_core_type *interp, char *str) { object_type *obj=0; obj=alloc_object(interp, FIXNUM); obj->value.int_val=strtoll(str, 0, 10); add_object(interp, obj); }
void Block::break_me() { auto sector = Sector::current(); sector->add_object( std::make_shared<BrokenBrick>(sprite->clone(), get_pos(), Vector(-100, -400))); sector->add_object( std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(0, 16), Vector(-150, -300))); sector->add_object( std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(16, 0), Vector(100, -400))); sector->add_object( std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(16, 16), Vector(150, -300))); remove_me(); }
/* * DER encode an OCTET STRING or BIT STRING */ DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length, ASN1_Tag real_type, ASN1_Tag type_tag, ASN1_Tag class_tag) { if(real_type != OCTET_STRING && real_type != BIT_STRING) throw Invalid_Argument("DER_Encoder: Invalid tag for byte/bit string"); if(real_type == BIT_STRING) { secure_vector<uint8_t> encoded; encoded.push_back(0); encoded += std::make_pair(bytes, length); return add_object(type_tag, class_tag, encoded); } else return add_object(type_tag, class_tag, bytes, length); }
std::size_t pointer_logict::add_object(const exprt &expr) { // remove any index/member if(expr.id()==ID_index) { assert(expr.operands().size()==2); return add_object(expr.op0()); } else if(expr.id()==ID_member) { assert(expr.operands().size()==1); return add_object(expr.op0()); } return objects.number(expr); }
//TODO: Add types to helpers. void Player::readWorld(std::string worldfilepath /*=WORLD_PHY_FNAME*/) { std::fstream f(worldfilepath , ios::in); if ( !f.is_open() ) { std::cout << "i gotcha. invalid file bruh.\n"; } string line1; getline(f,line1); std::istringstream lin1(line1); lin1 >> skybox_size >> SKYBOX_IMG >> maxHeightWithoutDamage; //Now, to do getlines until over. string line=""; int nline=0; bool flag = true; while(getline(f,line)) { //read line into vector. std::vector<float> parts; std::istringstream s(line); float temp2; std::string line_type=""; s >> line_type; while(!s.eof()){ s>>temp2; parts.push_back(temp2); } flag = true; //ASSERT : Done reading vector. OBJECT_TYPE world_obj_type = UFO; if ( line_type == "Endpoint" ) { world_obj_type = ENDPOINT; goalPos = btVector3(parts[0],0,parts[2]); //set the goal position. } else if ( line_type == "SkyriseTall" ) { world_obj_type = SKYRISE_TALL; } else if ( line_type == "SkyriseFat" ) { world_obj_type = SKYRISE_FAT; } else if ( line_type == "Asteroid") { world_obj_type = ASTEROID; } else if ( line_type == "Debris" ) { world_obj_type = DEBRIS; } else if (line_type == "AI") { flag = false; } if(flag) { SpaceObject* worldObject = new SpaceObject(world_obj_type); worldObject->init(bulletWorld); worldObject->setPosition( btVector3(parts[0] , parts[1] , parts[2]) ); bulletWorld->dynamicsWorld->stepSimulation(1/60000.0); if (world_obj_type==DEBRIS || world_obj_type==ENDPOINT || world_obj_type==SKYRISE_FAT || world_obj_type==SKYRISE_TALL) { worldObject->setStatic(); } add_object(worldObject); //pushes back a copy of the space object. i wonder if that matters. } else { //its an AI player, put him into a vector for akshay. valid_spawn.push_back(btVector3(parts[0],parts[1],parts[2])); } ++nline; } f.close(); }
void topo_add_object(struct topo_topology *topology, topo_obj_t obj) { if (topology->ignored_types[obj->type] == TOPO_IGNORE_TYPE_ALWAYS) return; /* Start at the top. */ add_object(topology, topology->levels[0][0], obj); }
static void init_obj(t_data *d) { t_object *o; d->o = NULL; o = add_object(d->o, SPHERE, VEC3(-1, 0, 10), 0.5); ((t_sphere*)o->obj)->color = put_col(CWHITE); d->o = o; o = add_object(d->o, SPHERE, VEC3(1, 0, 10), 1); ((t_sphere*)o->obj)->color = put_col(CWHITE); o = add_object(d->o, PLANE, VEC3(0, 1, 0), 2); ((t_plane*)o->obj)->color = put_col(CWHITE); o = add_object(d->o, CONE, VEC3(0, 0, 0), 1); ((t_cone*)o->obj)->color = put_col(CWHITE); }
/* create an instance of a string object */ void add_symbol(interp_core_type *interp, char *str) { object_type *obj=0; TRACE("Sy"); obj=create_symbol(interp, str); add_object(interp,obj); }
bool theme::set_resolution(const SDL_Rect& screen) { bool result = false; const config::child_list& resolutions = cfg_.get_children("resolution"); int current_rating = 1000000; config::child_list::const_iterator i; config::child_list::const_iterator current = resolutions.end(); for(i = resolutions.begin(); i != resolutions.end(); ++i) { const int width = atoi((**i)["width"].c_str()); const int height = atoi((**i)["height"].c_str()); LOG_DP << "comparing resolution " << screen.w << "," << screen.h << " to " << width << "," << height << "\n"; if(screen.w >= width && screen.h >= height) { LOG_DP << "loading theme: " << width << "," << height << "\n"; current = i; result = true; break; } const int rating = width*height; if(rating < current_rating) { current = i; current_rating = rating; } } if(current == resolutions.end()) { if(!resolutions.empty()) { LOG_STREAM(err, display) << "No valid resolution found\n"; } return false; } std::map<std::string,std::string> title_stash; std::vector<theme::menu>::iterator m; for (m = menus_.begin(); m != menus_.end(); ++m) { if (!m->title().empty() && !m->get_id().empty()) title_stash[m->get_id()] = m->title(); } panels_.clear(); labels_.clear(); status_.clear(); menus_.clear(); const config& cfg = **current; add_object(cfg); for (m = menus_.begin(); m != menus_.end(); ++m) { if (title_stash.find(m->get_id()) != title_stash.end()) m->set_title(title_stash[m->get_id()]); } theme_reset_.notify_observers(); return result; }
void rt_tri(void * tex, vector v0, vector v1, vector v2) { object * trn; trn = newtri(tex, (vector)v0, (vector)v1, (vector)v2); if (trn != NULL) { add_object(trn); } }
void rt_stri(void * tex, vector v0, vector v1, vector v2, vector n0, vector n1, vector n2) { object * trn; trn = newstri(tex, (vector)v0, (vector)v1, (vector)v2, (vector)n0, (vector)n1, (vector)n2); if (trn != NULL) { add_object(trn); } }
int FlowChart::add_elispse ( float x, float y, char* text ) { struct stFlowObject fo; fo.x = x; fo.y = y; fo.text = text; fo.shape = FLOW_ELIPSE; add_object( &fo ); return 1; }