bool CDecalsDrawerGL4::TryToCombineDecalGroups(SDecalGroup& g1, SDecalGroup& g2) { // g1 is full -> we cannot move anything from g2 to it if (g1.ids.back() != 0) return false; if (!Overlap(g1, g2)) return false; if ((g1.size() + g2.size()) <= CDecalsDrawerGL4::MAX_DECALS_PER_GROUP) { // move all g2 decals to g1 (and remove g2 later) for (int n = g1.size(), k = 0; n < g1.ids.size(); ++n,++k) { g1.ids[n] = g2.ids[k]; } g2.ids.fill(0); UpdateBoundingBox(g1); //UpdateBoundingBox(g2); gets removed, no reason to update return true; } // move n decals from g2 to g1 const int s = g1.size(); const int n = g1.ids.size() - s; memcpy(&g1.ids[s], &g2.ids[0], sizeof(int) * n); for (int i = 0; i<g2.ids.size(); ++i) { g2.ids[i] = ((n + i) < g2.ids.size()) ? g2.ids[n + i] : 0; } UpdateBoundingBox(g1); UpdateBoundingBox(g2); return false; }
void ceNode::FinishTransformationPrivate() { if (_parent) { _globalMatrix = _parent->_globalMatrix * _localMatrix; } else { _globalMatrix = _localMatrix; } if (_inversionDirty) { _localMatrixInverted = _localMatrix.FastInverted(); _globalMatrixInverted = _globalMatrix.FastInverted(); _inversionDirty = false; } // if this is an entity or something else that has data attached, this should get propagated UpdateTransformation(); for (int i=_children.size()-1; i>=0; --i) { ceNode* child = _children[i]; child->FinishTransformationPrivate(); } UpdateBoundingBox(); }
/*************************************************************//** * * @brief コンストラクタ * @param ID * @param 種類 * @param 座標 * ****************************************************************/ C_Stage01BossNormalBullet::C_Stage01BossNormalBullet(const std::string& rId, int32_t type, const Vector3& rPosition) : C_BaseBullet(rId, type, rPosition) { // ヒットポイントを生成 C_BaseBullet::upHitPoint_ = std::make_unique<C_BaseHitPoint>(1); // ステートを設定 upStateMachine_->SetCurrentState(C_BulletNormalState::s_GetInstance()); // スプライトの頂点を設定 spriteVertex_.position_ = position_; spriteVertex_.color_.Fill(1.0f); spriteVertex_.angle_ = 0.0f; spriteVertex_.size_.Fill(0.4f); spriteVertex_.textureSize_.Fill(1024.0f); spriteVertex_.textureUpperLeft_.x_ = 64.0f; spriteVertex_.textureUpperLeft_.y_ = 0.0f; spriteVertex_.textureLowerRight_.x_ = 96.0f; spriteVertex_.textureLowerRight_.y_ = 32.0f; boundingBoxHalfWidth_ = 0.2f; boundingBoxHalfHeight_ = 0.2f; // 境界ボックスを更新 UpdateBoundingBox(); pColliders_.emplace_back(newEx C_CircleCollider<>(IC_Collider2D<>::Vector2(position_.x_, position_.y_), 0.2f)); }
void ceNode::UpdateParentBoundingBox() { UpdateBoundingBox(); if (_parent) { _parent->UpdateParentBoundingBox(); } }
Entity* SkeletalEntity::SwapChild(Entity* orig, Entity* nchild){ int idx = mChildren.Find(orig); if(idx == Array<Entity*>::NOT_FOUND) return NULL; UnbindEntity(orig); mChildren[idx] = nchild; UpdateBoundingBox(); return orig; }
//--------------------------------------------------------------------------- void CMesh::ComputeBoundingBox(Vec3D<> &pmin, Vec3D<> &pmax) //--------------------------------------------------------------------------- { UpdateBoundingBox(); pmin = _CurBBMin; pmax = _CurBBMax; }
Entity* SkeletalEntity::RemoveChild(Entity* child){ int idx = mChildren.Find(child); if(idx == Array<Entity*>::NOT_FOUND) return NULL; UnbindEntity(child); mChildren.Erase(idx); UpdateBoundingBox(); return child; }
cArea2D::cArea2D(const tString& asName,const tString& asTypeName,cCollider2D* apCollider ) : iEntity2D(asName) { UpdateBoundingBox(); msType = asTypeName; mpCollider = apCollider; }
void iEntity2D::SetScale(const cVector3f& avScale) { mvLastScale = mvScale; mvScale = avScale; if(UpdateBoundingBox()) if(mpGridObject) mpGridObject->Update(GetBoundingBox()); }
//--------------------------------------------------------------------------- void CMesh::Translate(Vec3D<> d) //--------------------------------------------------------------------------- {// translate geometry for (int i=0; i<(int)Vertices.size(); i++) { Vertices[i].v += d; } UpdateBoundingBox(); MeshChanged(); }
long ExtObject::cOverlapAdvanced(LPVAL params) { CRunObjType* pType = params[0].GetObjectParam(pRuntime); if (pType == NULL) return FALSE; float oldx = info.x; float oldy = info.y; info.x += params[1].GetFloat(); info.y += params[2].GetFloat(); UpdateBoundingBox(); bool collision = pRuntime->QuerySelectCollision(this, pType); info.x = oldx; info.y = oldy; UpdateBoundingBox(); return collision; }
void iEntity2D::SetPosition(const cVector3f &a_vPos) { m_vLastPosition = m_vPosition; m_vPosition = a_vPos; if (UpdateBoundingBox()) if (m_pGridObject) m_pGridObject->Update(GetBoundingBox()); }
void iEntity2D::SetRotation(const cVector3f &a_vRot) { m_vLastRotation = m_vRotation; m_vRotation = a_vRot; if (UpdateBoundingBox()) if (m_pGridObject) m_pGridObject->Update(GetBoundingBox()); }
void iEntity2D::SetScale(const cVector3f &a_vScale) { m_vLastRotation = m_vScale; m_vScale = a_vScale; if (UpdateBoundingBox()) if (m_pGridObject) m_pGridObject->Update(GetBoundingBox()); }
void HeightMapPatch::UpdateBoundingGeometry(){ for (int x = xStart; x < xEnd; ++x){ for (int z = zStart; z < zEnd; ++z){ float y = terrain->GetVertex(x, z)[1]; min[1] = y < min[1] ? y : min[1]; max[1] = y > max[1] ? y : max[1]; } } UpdateBoundingBox(); }
void ExtObject::UpdateInfoBox() { info.angle=DEGREES(atan2(end.y-start.y,end.x-start.x)); info.x = start.x+((line_width/2)*cos(RADIANS(info.angle-90))); info.y = start.y+((line_width/2)*sin(RADIANS(info.angle-90))); info.w = sqrt(pow(end.x-start.x,2)+pow(end.y-start.y,2)); info.h = line_width; UpdateBoundingBox(); }
bool CDecalsDrawerGL4::AddDecalToGroup(SDecalGroup& g, const Decal& d, const int decalIdx) { if (g.ids.back() != 0) return false; if (!Overlap(g, d)) return false; auto it = spring::find(g.ids, 0); *it = decalIdx; UpdateBoundingBox(g); return true; }
//--------------------------------------------------------------------------- void CMesh::RotZ(vfloat a) //--------------------------------------------------------------------------- { for (int i=0; i<(int)Vertices.size(); i++) { Vertices[i].v.RotZ(a); Vertices[i].n.RotZ(a); } for (int i=0; i<(int)Facets.size(); i++) { Facets[i].n.RotZ(a); } UpdateBoundingBox(); MeshChanged(); }
void HeightMapPatch::SetupBoundingBox(){ min = Vector<3, float>(terrain->GetVertex(xStart, zStart)); max = Vector<3, float>(terrain->GetVertex(xEnd-1, zEnd-1)); for (int x = xStart; x < xEnd; ++x){ for (int z = zStart; z < zEnd; ++z){ float y = terrain->GetVertex(x, z)[1]; min[1] = y < min[1] ? y : min[1]; max[1] = y > max[1] ? y : max[1]; } } UpdateBoundingBox(); }
void CDecalsDrawerGL4::RemoveFromGroup(int idx) { for (auto it = groups.begin(); it != groups.end(); ++it) { SDecalGroup& g = *it; if (std::remove(g.ids.begin(), g.ids.end(), idx) != g.ids.end()) { g.ids.back() = 0; UpdateBoundingBox(g); if (g.ids.front() == 0) { groups.erase(it); } return; } } }
//--------------------------------------------------------------------------- void CMesh::Scale(Vec3D<> s) //--------------------------------------------------------------------------- {// scale geometry //check for zero scale factor if(s.x==0 || s.y==0 || s.z==0) return; for (int i=0; i<(int)Vertices.size(); i++) { Vertices[i].v.x *= s.x; Vertices[i].v.y *= s.y; Vertices[i].v.z *= s.z; // Vertices[i].n.x *= s.x; //do we really want to scale these? // Vertices[i].n.y *= s.y; // Vertices[i].n.z *= s.z; /// Facets[i].n.Normalize(); } UpdateBoundingBox(); MeshChanged(); }
//--------------------------------------------------------------------------- void CMesh::Rotate(Vec3D<> ax, vfloat a) //--------------------------------------------------------------------------- { for (int i=0; i<(int)Vertices.size(); i++) { Vertices[i].v = Vertices[i].v.Rot(ax, a); Vertices[i].n = Vertices[i].n.Rot(ax, a); Vertices[i].DrawOffset = Vertices[i].DrawOffset.Rot(ax, a); } for (int i=0; i<(int)Facets.size(); i++) { Facets[i].n = Facets[i].n.Rot(ax, a); } UpdateBoundingBox(); MeshChanged(); }
bool CDecalsDrawerGL4::FindAndAddToGroup(int decalIdx) { // first check if there is an existing fitting group Decal& d = decals[decalIdx]; for (SDecalGroup& g: groups) { if (AddDecalToGroup(g, d, decalIdx)) { return true; } } // no fitting one found, add new group if (groups.size() >= maxDecalGroups) return false; groups.emplace_back(); SDecalGroup& g = groups.back(); g.ids.fill(0); g.ids[0] = decalIdx; UpdateBoundingBox(g); return true; }
void HeightMapPatch::UpdateBoundingGeometry(float h){ if (h > max[1]){ // The vertex is above the box and the box should be // updated to the new height. max[1] = h; }else if (h < max[1]){ // Otherwise if the height is below the box check if // the roof of the box is still supported. float tempHeight = h; bool roofSupport = false; for (int x = xStart; x < xEnd && !roofSupport; ++x){ for (int z = zStart; z < zEnd && !roofSupport; ++z){ float y = terrain->GetVertex(x, z)[1]; roofSupport = y == max[1]; if (y > tempHeight) tempHeight = y; } } max[1] = tempHeight; } if (h < min[1]){ min[1] = h; }else if(h > min[1]){ float tempHeight = h; bool floorSupport = false; for (int x = xStart; x < xEnd && !floorSupport; ++x){ for (int z = zStart; z < zEnd && !floorSupport; ++z){ float y = terrain->GetVertex(x, z)[1]; floorSupport = y == min[1]; if (y < tempHeight) tempHeight = y; } } min[1] = tempHeight; } UpdateBoundingBox(); }
bool CMesh::LoadSTL(std::string filename) { FILE *fp; bool binary=false; #ifdef WIN32 fopen_s(&fp, filename.c_str(), "r"); //secure version. preferred on windows platforms... #else fp = fopen(filename.c_str(), "r"); #endif if(fp == NULL) return false; /* Find size of file */ fseek(fp, 0, SEEK_END); int file_size = ftell(fp); int facenum; /* Check for binary or ASCII file */ fseek(fp, STL_LABEL_SIZE, SEEK_SET); fread(&facenum, sizeof(int), 1, fp); int expected_file_size=STL_LABEL_SIZE + 4 + (sizeof(short)+12*sizeof(float) )*facenum ; if(file_size == expected_file_size) binary = true; unsigned char tmpbuf[128]; fread(tmpbuf,sizeof(tmpbuf),1,fp); for(unsigned int i = 0; i < sizeof(tmpbuf); i++){ if(tmpbuf[i] > 127){ binary=true; break; } } // Now we know if the stl file is ascii or binary. fclose(fp); bool RetVal; if(binary) RetVal = LoadBinarySTL(filename); else RetVal = LoadAsciiSTL(filename); UpdateBoundingBox(); //get the bounding box here and now... MeshChanged(); return RetVal; }
// Update the animation angle long ExtObject::aSetAnimationAngle(LPVAL theParams) { float given_angle = theParams[0].GetFloat(); // If animation angles are locked to object angle, the only way to set animation angle is to set the object angle if (locked_animation_angles) { info.angle = given_angle; UpdateBoundingBox(); } else { // Set the animation angle nearest to passed angle if(pRuntime->GetSubAngleAnimationCount(info.curAnim->pAnim->parent) != 1) { int anim = pRuntime->GetAnimationByNearestAngle(info.curAnim->handle, given_angle); if(info.curAnim->handle != anim) pRuntime->SetAnimation(anim, this); pRuntime->UpdateAnimationFrame(this); } } return 0; }
void Node::Update() { //Update opacity if(m_pParent) { m_color.a = m_pParent->GetOpacity() * m_localOpacity; } else { m_color.a = m_localOpacity; } UpdateTransform(); std::vector<Node*>::const_iterator it = m_children.begin(); std::vector<Node*>::const_iterator end = m_children.end(); while(it != end) { (*it)->Update(); ++it; } UpdateBoundingBox(); }
//----------------------------------------------------------------------------- // Compute position + bounding box //----------------------------------------------------------------------------- void CSpriteTrail::ClientThink() { // Update the trail + bounding box UpdateTrail(); UpdateBoundingBox(); }
bool Entity::Update() { float currentUpdateTime = EffectsLibrary::GetCurrentUpdateTime(); // Update speed in pixels per second if (_updateSpeed && _speed) { _pixelsPerSecond = _speed / currentUpdateTime; _speedVec.x = sinf(_direction / 180.0f * (float)M_PI) * _pixelsPerSecond; _speedVec.y = cosf(_direction / 180.0f * (float)M_PI) * _pixelsPerSecond; _x += _speedVec.x * _z; _y -= _speedVec.y * _z; } // update the gravity if (_weight != 0) { _gravity += _weight / currentUpdateTime; _y += (_gravity / currentUpdateTime) * _z; } // set the matrix if it is relative to the parent if (_relative) _matrix.Set(cosf(_angle / 180.f * (float)M_PI), sinf(_angle / 180.0f * (float)M_PI), -sinf(_angle / 180.0f * (float)M_PI), cosf(_angle / 180.0f * (float)M_PI)); // calculate where the entity is in the world if (_parent && _relative) { _z = _parent->_z; _matrix = _matrix.Transform(_parent->_matrix); Vector2 rotVec = _parent->_matrix.TransformVector(Vector2(_x, _y)); if (_z != 1.0f) { _wx = _parent->_wx + rotVec.x * _z; _wy = _parent->_wy + rotVec.y * _z; } else { _wx = _parent->_wx + rotVec.x; _wy = _parent->_wy + rotVec.y; } _relativeAngle = _parent->_relativeAngle + _angle; } else { // If parent setz(parent.z) _wx = _x; _wy = _y; } if (!_parent) _relativeAngle = _angle; // update animation frame if (_avatar && _animating) { _currentFrame += _framerate / currentUpdateTime; if (_animateOnce) { if (_currentFrame > _avatar->GetFramesCount() - 1) { _currentFrame = (float)(_avatar->GetFramesCount() - 1); } else if (_currentFrame <= 0) { _currentFrame = 0; } } } // update the Axis Aligned Bounding Box if (_AABB_Calculate) UpdateBoundingBox(); // update the radius of influence if (_radiusCalculate) UpdateEntityRadius(); // update the children UpdateChildren(); return true; }
/** * Tick the instance. * * @param DeltaTime The time slice to use * @param bSuppressSpawning If true, do not spawn during Tick */ void FParticleBeam2EmitterInstance::Tick(float DeltaTime, bool bSuppressSpawning) { SCOPE_CYCLE_COUNTER(STAT_BeamTickTime); if (Component) { UParticleLODLevel* LODLevel = SpriteTemplate->GetCurrentLODLevel(this); check(LODLevel); // TTP #33141 // Handle EmitterTime setup, looping, etc. float EmitterDelay = Tick_EmitterTimeSetup(DeltaTime, LODLevel); // Kill before the spawn... Otherwise, we can get 'flashing' KillParticles(); // If not suppressing spawning... if (!bHaltSpawning && !bSuppressSpawning && (EmitterTime >= 0.0f)) { if ((LODLevel->RequiredModule->EmitterLoops == 0) || (LoopCount < LODLevel->RequiredModule->EmitterLoops) || (SecondsSinceCreation < (EmitterDuration * LODLevel->RequiredModule->EmitterLoops))) { // For beams, we probably want to ignore the SpawnRate distribution, // and focus strictly on the BurstList... float SpawnRate = 0.0f; // Figure out spawn rate for this tick. SpawnRate = LODLevel->SpawnModule->Rate.GetValue(EmitterTime, Component); // Take Bursts into account as well... int32 Burst = 0; float BurstTime = GetCurrentBurstRateOffset(DeltaTime, Burst); SpawnRate += BurstTime; // Spawn new particles... //@todo. Fix the issue of 'blanking' beams when the count drops... // This is a temporary hack! const float InvDeltaTime = (DeltaTime > 0.0f) ? 1.0f / DeltaTime : 0.0f; if ((ActiveParticles < BeamCount) && (SpawnRate <= 0.0f)) { // Force the spawn of a single beam... SpawnRate = 1.0f * InvDeltaTime; } // Force beams if the emitter is marked "AlwaysOn" if ((ActiveParticles < BeamCount) && BeamTypeData->bAlwaysOn) { Burst = BeamCount; if (DeltaTime > KINDA_SMALL_NUMBER) { BurstTime = Burst * InvDeltaTime; SpawnRate += BurstTime; } } if (SpawnRate > 0.f) { SpawnFraction = SpawnBeamParticles(SpawnFraction, SpawnRate, DeltaTime, Burst, BurstTime); } } } // Reset particle data ResetParticleParameters(DeltaTime); // Not really necessary as beams do not LOD at the moment, but for consistency... CurrentMaterial = LODLevel->RequiredModule->Material; Tick_ModuleUpdate(DeltaTime, LODLevel); Tick_ModulePostUpdate(DeltaTime, LODLevel); // Calculate bounding box and simulate velocity. UpdateBoundingBox(DeltaTime); if (!bSuppressSpawning) { // Ensure that we flip the 'FirstEmission' flag FirstEmission = false; } // Invalidate the contents of the vertex/index buffer. IsRenderDataDirty = 1; // Bump the tick count TickCount++; // 'Reset' the emitter time so that the delay functions correctly EmitterTime += CurrentDelay; // Reset particles position offset PositionOffsetThisTick = FVector::ZeroVector; } INC_DWORD_STAT(STAT_BeamParticlesUpdateCalls); }