// Creates a body with the given type Body* World::createBody(BODY_TYPE bodyType, float xPos, float yPos) { Body* body = NULL; BodyReceptor* tempBodyReceptor = NULL; BodyEmitter* tempBodyEmitter = NULL; //BodyHybrid* tempBodyHybrid; // Switching body type. For the given type : create the Body with correct tag at correct position, and add it to the list of bodies switch (bodyType) { case BODY_TYPE::BODY_EMITTER : tempBodyEmitter = new BodyEmitter(Semantic(Tags::emitter), xPos, yPos); break; case BODY_TYPE::BODY_RECEPTOR_COMPOSITION: tempBodyReceptor = new BodyReceptor_Composition(Semantic(Tags::receptor), xPos, yPos); break; case BODY_TYPE::BODY_RECEPTOR_FULLCOMPOSITION: tempBodyReceptor = new BodyReceptor_CompositionFull(Semantic(Tags::receptor), xPos, yPos); break; case BODY_TYPE::BODY_RECEPTOR_MEDIUM: tempBodyReceptor = new BodyReceptor_Medium(Semantic(Tags::receptor), xPos, yPos); break; } if (tempBodyEmitter != NULL) { body = tempBodyEmitter; this->emitters.push_back(tempBodyEmitter); //cout << "PUSHED EMITTER BACK" << endl; // We've placed a new body : the max distance between an emitter and receptor may have changed updateMaxWaveDistance(); } else if (tempBodyReceptor != NULL) { body = tempBodyReceptor; this->receptors.push_back(tempBodyReceptor); // We've placed a new body : the max distance between an emitter and receptor may have changed updateMaxWaveDistance(); } return body; }
static std::unique_ptr<std::string> SemanticToGLSLKeywordPrimary(const IndexedSemantic& semantic) { static const auto typeMap = GenerateSemanticMap(); if (auto type = MapTypeToKeyword(typeMap, Semantic(semantic))) { if (type->hasIndex) return MakeUnique<std::string>(type->keyword + "[" + std::to_string(semantic.Index()) + "]"); else return MakeUnique<std::string>(type->keyword); } return nullptr; }
/* This function create a new wave Return type : Wave* x X position for the wave y Y position for the wave radius radius value for the wave frequency frequency value for the wave speed speed value for the wave amplitude amplitude value for the wave */ Wave* World::createWave(float x, float y, int emitterId, float speed, float amplitude) { // If speed wasn't specified, set it if (speed == -1.0f) speed = DEFAULT_PROPAGATION_SPEED * this->getWaveSpeed(); // Create a wave, add it to the list Wave * wave = new Wave(Semantic(Tags::wave), x, y, emitterId, speed, amplitude, this->waveAplitudeLoss, this->useWaveAttenuation); this->waves.push_back(wave); // return it return wave; }
bool Parameter::PerformSema( SemaAnalyzer& sema ) { DeclSpecs decl_specs; // // If there was a problem evaluating the declaration specifiers we can't // continue // if( !decl_specs.AnalyzeDeclSpecs( m_DeclarationSpecifiers, sema ) ) return false; // // Check some other things about the specifiers // if( decl_specs.IsInline() ) // Don't return here, this is a recoverable error sema.Error( "Can't have an 'inline' specifier on a parameter" ); if( decl_specs.IsStatic() ) sema.Error( "Can't have a 'static' specifier on a non-global " "variable" ); if( !decl_specs.IsUniform() ) decl_specs.SetIsVarying( true ); if( !(decl_specs.IsIn() || decl_specs.IsOut() ) ) // parameters are in by default decl_specs.SetIsIn( true ); Type base_type = decl_specs.GetType(); if( base_type == Type::UNKNOWN ) { sema.Error( "No type in declaration specifier" ); return false; } else if( base_type == Type::VOID ) { sema.Error( "Can't declare variables of void type" ); return false; } ArrayExtents array_extents =ArraySpecifier::GetArrayExtents( m_ArraySpecifers, sema ); if( array_extents.empty() && m_DefaultValue && m_DefaultValue->CanReduceToExpression() ) m_DefaultValue->ReduceToExpression(); if( m_DefaultValue ) m_DefaultValue->PerformSema( sema, CompleteType( base_type, array_extents ) ); if( !decl_specs.IsConst() && base_type == Type::STRING ) sema.Error( "Variables of type string must be const" ); if( m_DefaultValue && m_DefaultValue->GetArrayExtents() != array_extents ) sema.Error( "Default parameter value has mismatching array extents" ); Semantic semantic = m_SemanticSpecifier ? m_SemanticSpecifier->GetSemantic() : Semantic(); m_Variable = std::make_shared<Variable>( CompleteType( base_type, array_extents ), std::move(semantic), decl_specs.IsConst(), decl_specs.IsUniform(), decl_specs.IsVarying(), decl_specs.IsIn(), decl_specs.IsOut(), false, //Isn't global true, //Is a param GenericValue(), m_Identifier ); m_Type = CompleteType( base_type, std::move(array_extents) ); return true; }
// MotionTracker MotionTracker::MotionTracker() : DeviceTracker() { _jointsArray.resize(1); _jointsMap.insert(JointTracker::Map::value_type(Semantic("Root"), 0)); }