Beispiel #1
0
void setView(struct imageInfo *image, char *flakyClone, char *flakyStage,
	char *flakyView)
/* Set image->view from view name if it looks good. */
{
if (startsWith("2_", flakyView))
    flakyView += 2;
if (isAllish(flakyView))
    image->view = "mixed";
else if (isAnimal(flakyView))
    image->view = "animal";
else if (isAnterior(flakyView))
    image->view = "anterior";
else if (isBody(flakyView))
    image->view = "whole";
else if (isDorsal(flakyView))
    image->view = "dorsal";
else if (isTail(flakyView))
    image->view = "tail";
else if (isLateral(flakyView))
    image->view = "lateral";
else if (isPosterior(flakyView))
    image->view = "posterior";
else if (isSection(flakyView))
    image->view = "section";
else if (isVentral(flakyView))
    image->view = "ventral";
else if (isVegetal(flakyView))
    image->view = "vegetal";
else if (isHead(flakyView))
    image->view = "head";
}
//--------------------------------------------------------------
ofVec3f ofxBulletRigidBody::getBulletPosition() {
	if(!isBody()) return 0;
	btScalar m[16];
	btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
	myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
	btVector3 org(m[12], m[13], m[14]);
	return ofVec3f(org.x(), org.y(), org.z());
}
bool ofxBox2dBaseShape::isSleeping() {
    if(isBody()) {
        return !body->IsAwake();
    }
    else { 
        ofLog(OF_LOG_ERROR, "- body is not defined -");
        return false;
    }
}
//------------------------------------------------
void ofxBox2dConvexPoly::draw() {
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	ofScale(OFX_BOX2D_SCALE*scale, OFX_BOX2D_SCALE*scale);
	gpuCachedTesselation.draw();
	ofPopMatrix();
}
Beispiel #5
0
void ofxBox2dBody::_drawPolygon(b2Vec2 *vertices, int count) {
    
    if(!isBody()) {return;}
    
    ofBeginShape();
    for (int i=0; i<count; i++) {
        b2Vec2 vertex = vertices[i];
        vertex *= OFX_BOX2D_SCALE;
        ofVertex(vertex.x, vertex.y);
    }
    ofEndShape();
}
//------------------------------------------------
void ofxBox2dCircle::draw() {
	
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	ofCircle(0, 0, radius);
	ofSetColor(0);
	ofLine(0, 0, radius, 0);
	ofPopMatrix();
	
}
Beispiel #7
0
//------------------------------------------------ 
void ofxBox2dBaseShape::setData(void*data) {
	printf("data not set");

	if(data == NULL) {
		ofLog(OF_LOG_NOTICE, "- data is NULL -");
		return;
	}
	
	if(isBody()) {
		body->SetUserData(data);
	}
	else {
		ofLog(OF_LOG_NOTICE, "- must have a valid body -");
	}
}
Beispiel #8
0
void Boid::draw(){
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
    ofPushStyle();
    ofEnableAlphaBlending();
    ofSetColor(ofRandom(255),ofRandom(255),ofRandom(255));
    //	ofCircle(0, 0, getRadius());
    ofEllipse(ofVec2f(0,0), 10, 10);
    ofPopStyle();
    
	ofPopMatrix();
}
//------------------------------------------------ 
void* ofxBox2dBaseShape::setData(void*data) {
	
	if(data == NULL) {
		ofLog(OF_LOG_NOTICE, "- data is NULL -");
		return NULL;
	}
	
	if(isBody()) {
		ofLog(OF_LOG_NOTICE, "- custom data set %p", data);
		body->SetUserData(data);
		return data;
	}
	else {
		ofLog(OF_LOG_NOTICE, "- must have a valid body -");
	}
}
//------------------------------------------------
void ofxBox2dConvexPoly::setScale(float _scale){
    
    
    if(!isBody()) return;
    
    b2Fixture* fix = body->GetFixtureList();
    
    scale = _scale;
    
    b2PolygonShape* shape = (b2PolygonShape*) fix->GetShape();
    
    for (int i = 0; i < polyPts.size(); i++){
        shape->m_vertices[i].Set(polyPts[i].x*scale, polyPts[i].y*scale); 
    }
    
    
}
Beispiel #11
0
void Peg::draw(){
    
    if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	//ofCircle(0, 0, getRadius());
    
    ofNoFill();
    ofEnableSmoothing();
    ofSetLineWidth(2);
    ofCircle(0, 0, getRadius());
    ofDisableSmoothing();
    ofFill();
	
    ofPushStyle();
    ofEnableAlphaBlending();
    
    
    
    if(hl_alpha > 0){
        ofSetColor(highlight_color, hl_alpha);
        ofCircle(0, 0, getRadius());
        
        ofNoFill();
        ofEnableSmoothing();
        ofCircle(0, 0, getRadius()+(255-hl_alpha)/2);
        ofDisableSmoothing();
        ofFill();
        hl_alpha-=5;
    }

    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    ofPopStyle();
    

    ofPopMatrix();

}
Beispiel #12
0
void Mitosis::draw(){
    if(!isBody()) return;
    if(picked) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(rot, 0, 0, 1);
    
    ofSetCircleResolution(10);
    
    ofSetColor(120);
    ofCircle(-10, -5, 5);
    ofCircle(10, -5, 5);
    ofCircle(0, 10, 5);
    
    
    ofNoFill();
    ofEnableSmoothing();
    ofSetLineWidth(2);
    ofCircle(-10, -5, 5);
    ofCircle(10, -5, 5);
    ofCircle(0, 10, 5);
    ofSetColor(200);
    ofSetCircleResolution(30);
    ofCircle(0, 0, getRadius());
    ofDisableSmoothing();
    ofFill();
    
    ofPushStyle();
    ofEnableAlphaBlending();
    
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    
    ofPopStyle();
    
    ofPopMatrix();
    rot+=0.5;
    if((ofGetElapsedTimeMillis() - created) > lifespan ) dead = true;
}
Beispiel #13
0
//------------------------------------------------
void ofxBox2dLogo::draw() {
	
	if(!isBody()) return;
	
    radius = getRadius();

    rot += 1%360;
    //float var = ofRandom(10);
    glPushMatrix();
    glTranslatef(getPosition().x, getPosition().y, 0);
    
    ofSetColor(255);
    ofFill();
    ofRotate(rot);
    ofCircle(0,0, radius*2);
    logo.draw(-1.2 * radius, -1.2 * radius, radius * 2.4, radius * 2.4);
    
    glPopMatrix();
	
}
LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const LayoutPoint& startPoint) const
{
    // If the element is the HTML body element or doesn't have a parent
    // return 0 and stop this algorithm.
    if (isBody() || !parent())
        return LayoutPoint();

    LayoutPoint referencePoint = startPoint;
    referencePoint.move(parent()->columnOffset(referencePoint));

    // If the offsetParent of the element is null, or is the HTML body element,
    // return the distance between the canvas origin and the left border edge
    // of the element and stop this algorithm.
    Element* element = offsetParent();
    if (!element)
        return referencePoint;

    if (const RenderBoxModelObject* offsetParent = element->renderBoxModelObject()) {
        if (offsetParent->isBox() && !offsetParent->isBody())
            referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRenderBox(offsetParent)->borderTop());
        if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) {
            if (isRelPositioned())
                referencePoint.move(relativePositionOffset());

            RenderObject* current;
            for (current = parent(); current != offsetParent && current->parent(); current = current->parent()) {
                // FIXME: What are we supposed to do inside SVG content?
                if (!isOutOfFlowPositioned()) {
                    if (current->isBox() && !current->isTableRow())
                        referencePoint.moveBy(toRenderBox(current)->topLeftLocation());
                    referencePoint.move(current->parent()->columnOffset(referencePoint));
                }
            }

            if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent->isPositioned())
                referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation());
        }
    }

    return referencePoint;
}
Beispiel #15
0
void SParts::build(const Vector3d &ov, const Rotation &r, bool dynamics)
{
	if (isBody()) {
		const dReal *q = r.q();
		setPosition(ov);
		setQuaternion(q);
	}
	else {
		Vector3d v(m_pos.x(), m_pos.y(), m_pos.z());
		v.rotate(r);
		v += ov;
		setPosition(v);

		Rotation rr(r);
		rr *= m_rot;

		setRotation(rr);
	}

	enableDynamics(dynamics);
}
Beispiel #16
0
//------------------------------------------------
void ofxBox2dSnowFlake::draw() {
	
	if(!isBody()) return;
	
	radius = getRadius();
    rot += 0.7;
    //float var = ofRandom(10);
    glPushMatrix();
    glTranslatef(getPosition().x, getPosition().y, 0);
  //  ofRotateY(rot);
    ofRotateZ(rot);
    
    ofSetLineWidth(lineWidth);
    ofSetColor(color.r, color.g, color.b);
    for(int i=0; i < 180; i+= 90){
        ofRotate(i);
        ofLine(-1 * radius,0,radius,0);
        ofLine(0.66 * radius, 0, radius, 0.33 * radius); 
        ofLine(0.66 * radius, 0, radius, -0.33 * radius);
        ofLine(-0.66 * radius, 0, -1 * radius, 0.33 * radius);
        ofLine(-0.66 * radius, 0, -1 * radius, -0.33 * radius);
        
    }
    ofRotate(45);
    radius = radius + var;
    for(int i=0; i < 180; i += 90){
        ofRotate(i);
        ofLine(-1 * radius,0,radius,0);
        ofLine(0.66 * radius, 0, radius, 0.33 * radius); 
        ofLine(0.66 * radius, 0, radius, -0.33 * radius);
        ofLine(-0.66 * radius, 0, -1 * radius, 0.33 * radius);
        ofLine(-0.66 * radius, 0, -1 * radius, -0.33 * radius);
        
    }
    
    ofPopStyle();

    glPopMatrix();
	
}
Beispiel #17
0
//------------------------------------------------
void ofxBox2dCircle::draw() {
	
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	ofCircle(0, 0, radius);
	
    ofPushStyle();
    ofEnableAlphaBlending();
    ofSetColor(0);
	ofLine(0, 0, radius, 0);
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, radius);
    }
    ofPopStyle();
    
	ofPopMatrix();
	
}
//------------------------------------------------
ofPolyline& ofxBox2dRect::getRectangleShape() {
    
    if(isBody()) {
        
        shape.clear();
        const b2Transform& xf = body->GetTransform();
        
        for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext()) {
            b2PolygonShape* poly = (b2PolygonShape*)f->GetShape();
            if(poly) {
                for(int i=0; i<poly->m_count; i++) {
                    b2Vec2 pt = b2Mul(xf, poly->m_vertices[i]);
                    shape.addVertex(worldPtToscreenPt(pt));
                }
            }
        }
    }
    // we are a rectangle so close it
    shape.setClosed(true);
    return shape;
    
}
Beispiel #19
0
void SParts::calcPosture()
{
	assert(isBody());
	if (m_children.size() <= 0) { return; }

	const dReal *pos = getPosition();
	const dReal *q = getQuaternion();

	for (ChildC::iterator i=m_children.begin(); i!=m_children.end(); i++) {
		Child *child = *i;

		Vector3d v(pos[0], pos[1], pos[2]);

		Rotation r;
		r.setQuaternion(q);
		if (child->currj) {
			v += child->currj->getAnchor();
		}

		child->nextp->calcPosition(child->currj, child->nextj, v, r);
	}
}
Beispiel #20
0
void Star::draw() {
    if(!isBody()) return;
    if(picked) return;

    ofPushMatrix();
    ofTranslate(getPosition().x, getPosition().y, 0);
    ofRotate(getRotation(), 0, 0, 1);

    ofSetColor(241,241,5);
    ofCircle(0, 0, getRadius());

    ofPushStyle();
    ofEnableAlphaBlending();

    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    ofPopStyle();


    ofPopMatrix();
}
//--------------------------------------------------------------
void ofxBox2dCompoundShape::draw() {
    if(!isBody()) return;
    
    ofPushMatrix(); {
        ofTranslate(getPosition().x, getPosition().y, 0);
        ofRotateDeg(getRotation(), 0, 0, 1);
        
        ofPushStyle(); {
            ofNoFill();
            for( auto& shape : mShapes ) {
                if( shape->getType() == ofxBox2dCompoundShape::Shape::SHAPE_TYPE_CIRCLE ) {
                    auto circle = dynamic_pointer_cast<ofxBox2dCompoundShape::Circle>(shape);
                    ofDrawCircle(circle->x, circle->y, circle->radius);
                } else {
                    auto rect = dynamic_pointer_cast<ofxBox2dCompoundShape::Rectangle>(shape);
                    ofDrawRectangle( -rect->width/2.f+rect->x, -rect->height/2.f+rect->y, rect->width, rect->height );
                }
            }
            
        } ofPopStyle();
    
    } ofPopMatrix();
}
Beispiel #22
0
//----------------------------------------
void ofxBox2dBody::_drawCircle(b2Vec2 center, float radius) {
	
    if(!isBody()) {return;}
    
    center *= OFX_BOX2D_SCALE;
    radius *= OFX_BOX2D_SCALE;
    
    ofPushMatrix();
    ofTranslate(center.x, center.y);
    ofCircle(0, 0, radius);
    
    ofPushStyle();
    ofEnableAlphaBlending();
    ofSetColor(0);
    ofLine(0, 0, radius, 0);
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, radius);
    }
    ofPopStyle();
    
    ofPopMatrix();
    
}
/*
 * nbodyGravity: Walk the tree starting at the root to do force
 * calculations.
 *
 *
 * Random notes:
 *   - Not inlined without inline from multiple calls in
 *     mapForceBody(). Measurably better with the inline, but only
 *     slightly.
 */
static inline mwvector nbGravity(const NBodyCtx* ctx, NBodyState* st, const Body* p)
{
    mwbool skipSelf = FALSE;

    mwvector pos0 = Pos(p);
    mwvector acc0 = ZERO_VECTOR;

    const NBodyNode* q = (const NBodyNode*) st->tree.root; /* Start at the root */

    while (q != NULL)               /* while not at end of scan */
    {
        mwvector dr = mw_subv(Pos(q), pos0);   /* Then compute distance */
        real drSq = mw_sqrv(dr);               /* and distance squared */

        if (isBody(q) || (drSq >= Rcrit2(q)))      /* If is a body or far enough away to approximate */
        {
            if (mw_likely((const Body*) q != p))   /* self-interaction? */
            {
                real drab, phii, mor3;

                /* Compute gravity */

                drSq += ctx->eps2;   /* use standard softening */
                drab = mw_sqrt(drSq);
                phii = Mass(q) / drab;
                mor3 = phii / drSq;

                acc0.x += mor3 * dr.x;
                acc0.y += mor3 * dr.y;
                acc0.z += mor3 * dr.z;

                if (ctx->useQuad && isCell(q))          /* if cell, add quad term */
                {
                    real dr5inv, drQdr, phiQ;
                    mwvector Qdr;

                    /* form Q * dr */
                    Qdr.x = Quad(q).xx * dr.x + Quad(q).xy * dr.y + Quad(q).xz * dr.z;
                    Qdr.y = Quad(q).xy * dr.x + Quad(q).yy * dr.y + Quad(q).yz * dr.z;
                    Qdr.z = Quad(q).xz * dr.x + Quad(q).yz * dr.y + Quad(q).zz * dr.z;


                    /* form dr * Q * dr */
                    drQdr = Qdr.x * dr.x + Qdr.y * dr.y + Qdr.z * dr.z;

                    dr5inv = 1.0 / (sqr(drSq) * drab);  /* form dr^-5 */

                    /* get quad. part of phi */
                    phiQ = 2.5 * (dr5inv * drQdr) / drSq;

                    acc0.x += phiQ * dr.x;
                    acc0.y += phiQ * dr.y;
                    acc0.z += phiQ * dr.z;

                    /* acceleration */
                    acc0.x -= dr5inv * Qdr.x;
                    acc0.y -= dr5inv * Qdr.y;
                    acc0.z -= dr5inv * Qdr.z;
                }
            }
            else
            {
                skipSelf = TRUE;   /* Encountered self */
            }

            q = Next(q);  /* Follow next link */
        }
        else
        {
             q = More(q); /* Follow to the next level if need to go deeper */
        }
    }

    if (!skipSelf)
    {
        /* If a body does not encounter itself in its traversal of the
         * tree, it is "tree incest" */

        nbReportTreeIncest(ctx, st);
    }

    return acc0;
}
b2World* ofxBox2dBaseShape::getWorld() {
	if (isBody()) {
		return body->GetWorld();
	}
	return NULL;
}
//--------------------------------------------------------------
void ofxBulletRigidBody::draw() {
	
	/*
	 BOX_SHAPE_PROXYTYPE,
	 TRIANGLE_SHAPE_PROXYTYPE,
	 TETRAHEDRAL_SHAPE_PROXYTYPE,
	 CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
	 CONVEX_HULL_SHAPE_PROXYTYPE,
	 CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
	 CUSTOM_POLYHEDRAL_SHAPE_TYPE,
	 //implicit convex shapes
	 IMPLICIT_CONVEX_SHAPES_START_HERE,
	 SPHERE_SHAPE_PROXYTYPE,
	 MULTI_SPHERE_SHAPE_PROXYTYPE,
	 CAPSULE_SHAPE_PROXYTYPE,
	 CONE_SHAPE_PROXYTYPE,
	 CONVEX_SHAPE_PROXYTYPE,
	 CYLINDER_SHAPE_PROXYTYPE,
	 UNIFORM_SCALING_SHAPE_PROXYTYPE,
	 MINKOWSKI_SUM_SHAPE_PROXYTYPE,
	 MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
	 CUSTOM_CONVEX_SHAPE_TYPE,
	 
	 
	 //cout << colShape->getShapeType() << endl;
	 //drawer.drawOpenGL(m, shape, btVector3(1, 0, 0), 0, aabbMin, aabbMax, ofxBulletStaticUtil::ofxVec4ToBtVec4(bodyColor));
	 
	 
	 */
	if(isBody()) {
		
		btPolyhedralConvexShape* colShape = (btPolyhedralConvexShape*)body->getCollisionShape();
		btScalar	m[16];
		body->getWorldTransform().getOpenGLMatrix(m);
		btVector3 aabbMin, aabbMax;
		world->getBroadphase()->getBroadphaseAabb(aabbMin, aabbMax);
		int type = colShape->getShapeType();
		
		
		// ----------------------
		// mult to the body matrix
		// ----------------------
		glPushMatrix(); 
		glTranslatef(0, 0, 0);
		glMultMatrixf(m);
		
		// ----------------------
		// box
		// ----------------------
		if(type == BOX_SHAPE_PROXYTYPE) {
			
			const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
			btVector3 halfExtent = boxShape->getHalfExtentsWithMargin();
			static int indices[36] = {
				0,1,2,
				3,2,1,
				4,0,6,
				6,0,2,
				5,1,4,
				4,1,0,
				7,3,1,
				7,1,5,
				5,4,7,
				7,4,6,
				7,2,3,
				7,6,2};
			static btVector3 vertices[8]={	btVector3(1,1,1),btVector3(-1,1,1),	btVector3(1,-1,1),	btVector3(-1,-1,1),	btVector3(1,1,-1),	btVector3(-1,1,-1),	btVector3(1,-1,-1),	btVector3(-1,-1,-1)};
			glBegin (GL_TRIANGLES);
			int si=36;
			for (int i=0;i<si;i+=3) {
				btVector3 v1 = vertices[indices[i]]*halfExtent;
				btVector3 v2 = vertices[indices[i+1]]*halfExtent;
				btVector3 v3 = vertices[indices[i+2]]*halfExtent;
				
				//v1 *= SCALE;
				//v2 *= SCALE;
				//v3 *= SCALE;
				
				btVector3 normal = (v3-v1).cross(v2-v1);
				normal.normalize ();
				
				glNormal3f(normal.getX(),normal.getY(),normal.getZ());
				glVertex3f (v1.x(), v1.y(), v1.z());
				glVertex3f (v2.x(), v2.y(), v2.z());
				glVertex3f (v3.x(), v3.y(), v3.z());
			}
			glEnd();
			
			
		}
		
		// ----------------------
		// Shpere
		// ----------------------
		else if(type == SPHERE_SHAPE_PROXYTYPE) {
			
			const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
			float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
			ofSphere(0, 0, 0, radius);
			
		}
		
		
		// ----------------------
		// end move
		// ----------------------
		glPopMatrix();
		
	}
	
	
	
	
	/*
	 
	 
	 btPolyhedralConvexShape * shape = (btPolyhedralConvexShape*)psb->getCollisionShape();
	 btScalar	m[16];
	 psb->getWorldTransform().getOpenGLMatrix(m);
	 btVector3 aabbMin,aabbMax;
	 dynamicsWorld->getBroadphase()->getBroadphaseAabb(aabbMin,aabbMax);
	 
	 const btSphereShape* sphereShape = (btSphereShape*)shape;//static_cast<const btSphereShape*>(shape);
	 float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
	 //drawSphere(radius,10,10);
	 //useWireframeFallback = false;
	 
	 //btScalar m[16];
	 btDefaultMotionState* myMotionState = (btDefaultMotionState*)psb->getMotionState();
	 myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
	 btVector3 org(m[12], m[13], m[14]);
	 ofPoint p(org.x(), org.y(), org.z());
	 
	 
	 glPushMatrix(); 
	 glMultMatrixf(m);
	 ofSphere(0, 0, 0, radius);
	 glPopMatrix();
	 //drawer.drawOpenGL(m, shape, btVector3(1, 0, 0), 0, aabbMin, aabbMax, ofxBulletStaticUtil::ofxVec4ToBtVec4(bodyColor));
	 */
	
}
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    RenderElement::styleDidChange(diff, oldStyle);
    updateFromStyle();

    if (requiresLayer()) {
        if (!layer() && layerCreationAllowedForSubtree()) {
            if (s_wasFloating && isFloating())
                setChildNeedsLayout();
            createLayer();
            if (parent() && !needsLayout() && containingBlock()) {
                layer()->setRepaintStatus(NeedsFullRepaint);
                // There is only one layer to update, it is not worth using |cachedOffset| since
                // we are not sure the value will be used.
                layer()->updateLayerPositions(0);
            }
        }
    } else if (layer() && layer()->parent()) {
#if ENABLE(CSS_COMPOSITING)
        if (oldStyle->hasBlendMode())
            layer()->parent()->dirtyAncestorChainHasBlendingDescendants();
#endif
        setHasTransformRelatedProperty(false); // All transform-related propeties force layers, so we know we don't have one or the object doesn't support them.
        setHasReflection(false);
        // Repaint the about to be destroyed self-painting layer when style change also triggers repaint.
        if (layer()->isSelfPaintingLayer() && layer()->repaintStatus() == NeedsFullRepaint)
            repaintUsingContainer(containerForRepaint(), layer()->repaintRect());
        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
        if (s_wasFloating && isFloating())
            setChildNeedsLayout();
        if (s_hadTransform)
            setNeedsLayoutAndPrefWidthsRecalc();
    }

    if (layer()) {
        layer()->styleChanged(diff, oldStyle);
        if (s_hadLayer && layer()->isSelfPaintingLayer() != s_layerWasSelfPainting)
            setChildNeedsLayout();
    }

    bool newStyleIsViewportConstrained = style().hasViewportConstrainedPosition();
    bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
    if (newStyleIsViewportConstrained != oldStyleIsViewportConstrained) {
        if (newStyleIsViewportConstrained && layer())
            view().frameView().addViewportConstrainedObject(this);
        else
            view().frameView().removeViewportConstrainedObject(this);
    }

#if ENABLE(CSS_SCROLL_SNAP)
    const RenderStyle& newStyle = style();
    if (oldStyle && scrollSnapContainerRequiresUpdateForStyleUpdate(*oldStyle, newStyle)) {
        if (RenderLayer* renderLayer = layer()) {
            renderLayer->updateSnapOffsets();
            renderLayer->updateScrollSnapState();
        } else if (isBody() || isDocumentElementRenderer()) {
            FrameView& frameView = view().frameView();
            frameView.updateSnapOffsets();
            frameView.updateScrollSnapState();
            frameView.updateScrollingCoordinatorScrollSnapProperties();
        }
    }
    if (oldStyle && oldStyle->scrollSnapCoordinates() != newStyle.scrollSnapCoordinates()) {
        const RenderBox* scrollSnapBox = enclosingBox().findEnclosingScrollableContainer();
        if (scrollSnapBox && scrollSnapBox->layer()) {
            const RenderStyle& style = scrollSnapBox->style();
            if (style.scrollSnapType() != ScrollSnapType::None) {
                scrollSnapBox->layer()->updateSnapOffsets();
                scrollSnapBox->layer()->updateScrollSnapState();
                if (scrollSnapBox->isBody() || scrollSnapBox->isDocumentElementRenderer())
                    scrollSnapBox->view().frameView().updateScrollingCoordinatorScrollSnapProperties();
            }
        }
    }
#endif
}