// The default implementation just returns true here bool insula::physics::broadphase::culler::Descent( btDbvtNode const *) { FCPPT_ASSERT(false); return true; }
// The default implementation does nothing here void insula::physics::broadphase::culler::Process( btDbvtNode const *node) { FCPPT_ASSERT(node); FCPPT_ASSERT(node->data); FCPPT_ASSERT(!node->isinternal()); // The DbvtBroadphase puts the broadphase proxies to the data field // in the tree (apparently). // btCollisionWorld replaces the m_clientObject pointer by the // btCollisionObject // Finally, _we_ set the collision object's user pointer. static_cast<object *>( static_cast<btCollisionObject *>( static_cast<btBroadphaseProxy *>( node->data)->m_clientObject)->getUserPointer())->last_seen(iteration_); }
void insula::physics::debug_drawer::render() { lines_.clear(); world_.handle().debugDrawWorld(); if (lines_.empty()) return; FCPPT_ASSERT( lines_.size() % 2 == 0); sge::renderer::state::scoped const sstate( renderer_, sge::renderer::state::list (sge::renderer::state::depth_func::less)); graphics::shader::scoped scoped_shader_( shader_); shader_.set_uniform( FCPPT_TEXT("mvp"), camera_.perspective() * camera_.world()); vb_ = renderer_->create_vertex_buffer( sge::renderer::vf::dynamic::make_format<vertex_format>(), static_cast<sge::renderer::size_type>( lines_.size()), sge::renderer::resource_flags::none); sge::renderer::scoped_vertex_buffer const scoped_vb_( renderer_, vb_); { sge::renderer::scoped_vertex_lock const vblock( vb_, sge::renderer::lock_mode::writeonly); vertex_view const vertices( vblock.value()); vertex_view::iterator vb_it( vertices.begin()); BOOST_FOREACH(line_cache::const_reference l,lines_) { // Technically, we'd have to cast to vf_position::packed_type // here, but screw that (vb_it)->set<vf_position>( std::get<0>(l)); (vb_it++)->set<vf_color>( std::get<1>(l)); } }
typename Container::size_type chain_length( Container const &_c, typename Container::size_type const _original_pos) { FCPPT_ASSERT( !_c.empty() && _original_pos < _c.size()); typename Container::size_type pos = _original_pos+1; while (pos != _c.size() && _c[pos] == _c[_original_pos]) ++pos; return static_cast<typename Container::size_type>( pos - _original_pos); }
insula::textures::rgb_store const insula::textures::blend( rgb_view const &gradient_image, rgb_view_sequence const &images, height_map::array const &heights, height_map::array const &grad, interpolators::base &lerper) { FCPPT_ASSERT( !images.empty()); FCPPT_ASSERT( std::all_of( images.begin(), images.end(), [&images](rgb_view const &f) { return f.dim() == images.front().dim(); }) && gradient_image.dim() == images.front().dim()); rgb_store m( images.front().dim()); rgb_store::view_type target = m.view(); for (rgb_store::dim_type::value_type y = 0; y < target.dim()[1]; ++y) { for (rgb_store::dim_type::value_type x = 0; x < target.dim()[0]; ++x) { weights const w = lerper.calculate_weights( static_cast<weight>( heights[height_map::array::dim(x,y)]), static_cast<weight>( grad[height_map::array::dim(x,y)])); FCPPT_ASSERT( static_cast<weights::weight_sequence::size_type>(w.sequence().size()) == static_cast<weights::weight_sequence::size_type>(images.size())); //fcppt::io::cout << "weight sequence: "; //BOOST_FOREACH(weights::weight_sequence::const_reference r,w) // fcppt::io::cout << r << ","; //fcppt::io::cout << "\n"; // Current position rgb_store::dim_type const cp( x, y); target.at(cp) = w.gradient() * gradient_image.at(cp); rgb_view_sequence::const_iterator view_it = images.begin(); for (weights::weight_sequence::const_iterator i = w.sequence().begin(); i != w.sequence().end(); ++i) target.at(cp) = target.at(cp) + (*i) * (view_it++)->at(cp); } } return m; }
result_type operator()( T const &t) const { typedef typename T::value_type value_type; typename T::iterator it = t.begin(); size_type indices = 0; // First, the triangles at the top for (size_type lons = 1; lons <= it_lon; ++lons) { /* DEBUG fcppt::io::cout << "Adding triangle: " << 0 << "," << ((lons == it_lon) ? 1 : (lons+1)) << "," << lons << "\n";*/ *it++ = 0; *it++ = static_cast<value_type>( lons == it_lon ? 1 : (lons+1)); *it++ = static_cast<value_type>( lons); indices += 3; } // Start at the first vertex after the top value_type current = 1; // Again, we have it_lat-1 ring pairs (see below) for (size_type lats = 0; lats < static_cast<size_type>(it_lat-1); ++lats) { // Remember the beginning index of the current circle so we can wrap around later in the inner loop value_type const beginning = current; // The last index would wrap around the first one, so it_lon-1 for (size_type lon = 0; lon < static_cast<size_type>(it_lon); ++lon) { value_type const next = lon == static_cast<size_type>(it_lon-1) ? static_cast<value_type>(beginning) : static_cast<value_type>( current+1), below = static_cast<value_type>( current + it_lon), next_below = lon == static_cast<size_type>(it_lon-1) ? static_cast<value_type>( beginning + it_lon) : static_cast<value_type>( below+1); *it++ = current; *it++ = next_below; *it++ = below; *it++ = current; *it++ = next_below; *it++ = next; indices += 6; ++current; } } FCPPT_ASSERT(indices <= ib_size); }
extract::process::output const extract::process::call( argument_list const &_args) { FCPPT_ASSERT( !_args.empty()); std::size_t const reading_end = static_cast<std::size_t>( 0), writing_end = static_cast<std::size_t>( 1); int out_pipe[2]; int err_pipe[2]; if (pipe(out_pipe) == -1 || pipe(err_pipe) == -1) throw fcppt::exception( FCPPT_TEXT("one of the pipes failed")); pid_t const pid = fork(); if (pid == 0) { close( out_pipe[reading_end]); close( err_pipe[reading_end]); dup2( out_pipe[writing_end], STDOUT_FILENO); dup2( err_pipe[writing_end], STDERR_FILENO); close( out_pipe[writing_end]); close( err_pipe[writing_end]); exec( _args); } close( out_pipe[writing_end]); close( err_pipe[writing_end]); fd_set master_fds; FD_ZERO( &master_fds); FD_SET( out_pipe[reading_end], &master_fds); FD_SET( err_pipe[reading_end], &master_fds); output out; int eof_count = 0; while (eof_count < 2) { fd_set read_fds = master_fds; int maxfd = std::max( out_pipe[reading_end], err_pipe[reading_end]), select_return = select( maxfd+1, &read_fds, 0, 0, 0); if (select_return == -1) throw fcppt::exception( FCPPT_TEXT("select failed")); int const fds[2] = { out_pipe[reading_end], err_pipe[reading_end] }; fcppt::string *outs[2] = { &out.out, &out.err }; for (int i = 0; i < 2; ++i) { if (!FD_ISSET(fds[i],&read_fds)) continue; ssize_t const buffer_size = static_cast<ssize_t>( 1024); char char_buffer[buffer_size]; ssize_t const b = ::read( fds[i], char_buffer, static_cast<std::size_t>( buffer_size-1)); if (b == static_cast<ssize_t>(0)) { // fcppt::io::cerr << "recieved eof on fd " << fds[i] << "\n"; eof_count++; FD_CLR( fds[i], &master_fds); continue; } if (b == static_cast<ssize_t>(-1)) throw fcppt::exception( FCPPT_TEXT("read failed")); // fcppt::io::cerr << "received the following crap: " << fcppt::string(char_buffer,char_buffer+b) << "\n"; outs[i]->insert( outs[i]->end(), char_buffer, char_buffer + b); } } waitpid( pid, (&out.exit_code), 0); return out; }