@@ -628,6 +628,10 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
628628// wkLog("----");
629629
630630 for (auto layoutObj : container.objs ) {
631+ layoutObj->newEnable = false ;
632+ layoutObj->obj .layoutModelPlaces .clear ();
633+ layoutObj->obj .layoutPlaces .clear ();
634+
631635 // Layout along a shape
632636 if (!layoutObj->obj .layoutShape .empty ()) {
633637 // Sometimes there are just a few instances
@@ -646,7 +650,7 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
646650 std::vector<Point3d> layoutModelInstances;
647651
648652 auto runs = textBuilder.getScreenVecs ();
649- // unsigned int ri=0;
653+ unsigned int ri=0 ;
650654 for (auto run: runs) {
651655// wkLog("Run %d",ri++);
652656
@@ -672,8 +676,9 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
672676
673677 // Center around the world point on the screen
674678 Point2f midRun;
675- if (!walk.nextPoint (layoutMbr.span ().x ()/2.0 , &midRun, nullptr , false ))
679+ if (!walk.nextPoint (resScale * layoutMbr.span ().x ()/2.0 , &midRun, nullptr , false ))
676680 continue ;
681+ // wkLogLevel(Info, "midRun = (%f,%f)",midRun.x(),midRun.y());
677682 Point2f worldScreenPt = midRun;
678683 Point3d worldPt (0.0 ,0.0 ,0.0 );
679684 if (!textBuilder.screenToWorld (midRun, worldPt))
@@ -711,36 +716,34 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
711716
712717 // Translate the glyph into that position
713718 Affine2d transPlace (Translation2d ((centerPt.x ()-worldScreenPt.x ())/2.0 ,
714- -(centerPt .y ()-worldScreenPt .y ())/2.0 ));
719+ (worldScreenPt .y ()-centerPt .y ())/2.0 ));
715720 double ang = -1.0 * (atan2 (norm.y (),norm.x ()) - M_PI/2.0 );
716721 Matrix2d screenRot = Eigen::Rotation2Dd (ang).matrix ();
717722 Matrix3d screenRotMat = Matrix3d::Identity ();
718723 for (unsigned ix=0 ;ix<2 ;ix++)
719724 for (unsigned iy=0 ;iy<2 ;iy++)
720725 screenRotMat (ix, iy) = screenRot (ix, iy);
726+ Matrix3d overlapMat = transPlace.matrix () * screenRotMat * transOrigin.matrix ();
721727 Matrix3d scaleMat = Eigen::AlignedScaling3d (resScale,resScale,1.0 );
722- Matrix3d overlapMat = transPlace.matrix () * screenRotMat * scaleMat * transOrigin.matrix ();
723- // Matrix3d overlapMat = transPlace.matrix() * transOrigin.matrix();
724- layoutMats.push_back (transPlace.matrix () * screenRotMat * transOrigin.matrix ());
725- // layoutMats.push_back(transPlace.matrix() * transOrigin.matrix());
728+ Matrix3d testMat = screenRotMat * scaleMat * transOrigin.matrix ();
729+ layoutMats.push_back (overlapMat);
726730
727731 // Check for overlap
728732 Point2dVector objPts; objPts.reserve (4 );
729733 for (unsigned int oi=0 ;oi<4 ;oi++) {
730- Point3d pt = overlapMat * Point3d (geom.coords [oi].x (),geom.coords [oi].y (),1.0 );
731- Point2d objPt (pt.x ()+worldScreenPt .x (),pt.y ()+worldScreenPt .y ());
734+ Point3d pt = testMat * Point3d (geom.coords [oi].x (),geom.coords [oi].y (),1.0 );
735+ Point2d objPt (pt.x ()+centerPt .x (),pt.y ()+centerPt .y ());
732736 objPts.push_back (objPt);
733737 }
734738
735739// if (!failed) {
736740// wkLog(" Geometry %d",ig);
737741// for (unsigned int ip=0;ip<objPts.size();ip++) {
738- // wkLog(" (%f,%f)",objPts[ip].x(),frameBufferSize.y()- objPts[ip].y());
742+ // wkLog(" (%f,%f)",objPts[ip].x(),objPts[ip].y());
739743// }
740744// }
741745
742746 if (!overlapMan.checkObject (objPts)) {
743- // wkLog(" Failed");
744747 failed = true ;
745748 break ;
746749 }
@@ -749,7 +752,7 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
749752 }
750753
751754 if (!failed) {
752- layoutObj->obj .setRotation (textBuilder.getViewStateRotation ());
755+ // layoutObj->obj.setRotation(textBuilder.getViewStateRotation());
753756 layoutModelInstances.push_back (worldPt);
754757 layoutInstances.push_back (layoutMats);
755758 numInstances++;
@@ -778,9 +781,6 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
778781 layoutObj->offset = Point2d (0.0 ,0.0 );
779782 } else {
780783 isActive = false ;
781- layoutObj->newEnable = false ;
782- layoutObj->obj .layoutPlaces .clear ();
783- layoutObj->obj .layoutModelPlaces .clear ();
784784 }
785785
786786 if (layoutObj->currentEnable != isActive) {
@@ -891,10 +891,10 @@ bool LayoutManager::runLayoutRules(PlatformThreadInfo *threadInfo,
891891 }
892892 }
893893
894- // wkLogLevel(Debug, "Center pt = (%f,%f), orient = %d",objPt.x(),objPt.y(),orient);
895- // wkLogLevel(Debug, "Layout Pts");
896- // for (unsigned int xx=0;xx<objPts.size();xx++)
897- // wkLogLevel(Debug, " (%f,%f)\n",objPts[xx].x(),objPts[xx].y());
894+ // wkLogLevel(Debug, "Center pt = (%f,%f), orient = %d",objPt.x(),objPt.y(),orient);
895+ // wkLogLevel(Debug, "Layout Pts");
896+ // for (unsigned int xx=0;xx<objPts.size();xx++)
897+ // wkLogLevel(Debug, " (%f,%f)\n",objPts[xx].x(),objPts[xx].y());
898898
899899 // Now try it. Objects we've pegged as essential always win
900900 if (overlapMan.addCheckObject (objPts) || container.importance >= MAXFLOAT)
@@ -1038,24 +1038,25 @@ void LayoutManager::updateLayout(PlatformThreadInfo *threadInfo,const ViewStateR
10381038 // animObj.setDrawOrder(?)
10391039 for (auto &geom : animObj.geometry )
10401040 geom.progID = params.motionShaderID ;
1041- ssBuild.addScreenObject (animObj,animObj.worldLoc ,animObj.geometry );
1041+ ssBuild.addScreenObject (animObj,animObj.worldLoc ,& animObj.geometry );
10421042
10431043 // And hold off on adding it
10441044 // todo: slicing, is this ok?
10451045 ScreenSpaceObject shortObj = layoutObj->obj ;
10461046 // shortObj.setDrawOrder(?)
10471047 shortObj.setEnableTime (curTime+params.markerAnimationTime , 0.0 );
1048- ssBuild.addScreenObject (shortObj,shortObj.worldLoc ,shortObj.geometry );
1048+ ssBuild.addScreenObject (shortObj,shortObj.worldLoc ,& shortObj.geometry );
10491049 } else {
10501050 // It's boring, just add it
10511051 if (layoutObj->newEnable ) {
10521052 // It's a single point placement
10531053 if (layoutObj->obj .layoutShape .empty ())
1054- ssBuild.addScreenObject (layoutObj->obj ,layoutObj->obj .worldLoc ,layoutObj->obj .geometry );
1054+ ssBuild.addScreenObject (layoutObj->obj ,layoutObj->obj .worldLoc ,& layoutObj->obj .geometry );
10551055 else {
10561056 // One or more placements along a path
1057- for (unsigned int ii=0 ;ii<layoutObj->obj .layoutPlaces .size ();ii++)
1058- ssBuild.addScreenObject (layoutObj->obj , layoutObj->obj .layoutModelPlaces [ii], layoutObj->obj .geometry , &layoutObj->obj .layoutPlaces [ii]);
1057+ for (unsigned int ii=0 ;ii<layoutObj->obj .layoutPlaces .size ();ii++) {
1058+ ssBuild.addScreenObject (layoutObj->obj , layoutObj->obj .layoutModelPlaces [ii], &layoutObj->obj .geometry , &layoutObj->obj .layoutPlaces [ii]);
1059+ }
10591060 }
10601061 }
10611062 }
@@ -1092,16 +1093,16 @@ void LayoutManager::updateLayout(PlatformThreadInfo *threadInfo,const ViewStateR
10921093 // animObj.setDrawOrder(?)
10931094 for (auto &geom : animObj.geometry )
10941095 geom.progID = params.motionShaderID ;
1095- ssBuild.addScreenObject (animObj, animObj.worldLoc , animObj.geometry );
1096+ ssBuild.addScreenObject (animObj, animObj.worldLoc , & animObj.geometry );
10961097
10971098 // Hold off on adding the new one
10981099 ScreenSpaceObject shortObj = cluster.layoutObj ;
10991100 // shortObj.setDrawOrder(?)
11001101 shortObj.setEnableTime (curTime+params.markerAnimationTime , 0.0 );
1101- ssBuild.addScreenObject (shortObj, shortObj.worldLoc , shortObj.geometry );
1102+ ssBuild.addScreenObject (shortObj, shortObj.worldLoc , & shortObj.geometry );
11021103
11031104 } else
1104- ssBuild.addScreenObject (cluster.layoutObj , cluster.layoutObj .worldLoc , cluster.layoutObj .geometry );
1105+ ssBuild.addScreenObject (cluster.layoutObj , cluster.layoutObj .worldLoc , & cluster.layoutObj .geometry );
11051106 }
11061107
11071108 ssBuild.flushChanges (changes, drawIDs);
0 commit comments