MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / RotateAndScaleObjects

Function RotateAndScaleObjects

roomedit/source/objects.cpp:1656–1761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1654*/
1655
1656void RotateAndScaleObjects (int objtype, SelPtr obj, double angle, double scale)
1657{
1658 SHORT n, m;
1659 SHORT dx, dy;
1660 SHORT centerx, centery;
1661 LONG accx, accy, num;
1662 SelPtr cur, vertices;
1663
1664 if (obj == NULL)
1665 return;
1666
1667 switch (objtype)
1668 {
1669 case OBJ_THINGS:
1670 accx = 0L;
1671 accy = 0L;
1672 num = 0L;
1673 for (cur = obj; cur; cur = cur->next)
1674 {
1675 assert_tnum(cur->objnum);
1676 Thing *pThing = &Things[cur->objnum];
1677
1678 accx += (LONG) pThing->xpos;
1679 accy += (LONG) pThing->ypos;
1680 num++;
1681 }
1682 centerx = (SHORT) ((accx + num / 2L) / num);
1683 centery = (SHORT) ((accy + num / 2L) / num);
1684
1685 for (cur = obj; cur; cur = cur->next)
1686 {
1687 assert_tnum(cur->objnum);
1688 Thing *pThing = &Things[cur->objnum];
1689
1690 dx = pThing->xpos - centerx;
1691 dy = pThing->ypos - centery;
1692 RotateAndScaleCoords (&dx, &dy, angle, scale);
1693 pThing->xpos = centerx + dx;
1694 pThing->ypos = centery + dy;
1695 }
1696 MadeChanges = TRUE;
1697 break;
1698
1699 case OBJ_VERTEXES:
1700 accx = 0L;
1701 accy = 0L;
1702 num = 0L;
1703 for (cur = obj; cur; cur = cur->next)
1704 {
1705 accx += (LONG) Vertexes[ cur->objnum].x;
1706 accy += (LONG) Vertexes[ cur->objnum].y;
1707 num++;
1708 }
1709 centerx = (SHORT) ((accx + num / 2L) / num);
1710 centery = (SHORT) ((accy + num / 2L) / num);
1711
1712 for (cur = obj; cur; cur = cur->next)
1713 {

Callers 1

CmMiscRotateScaleMethod · 0.85

Calls 4

RotateAndScaleCoordsFunction · 0.85
SelectObjectFunction · 0.85
ForgetSelectionFunction · 0.85
IsSelectedFunction · 0.70

Tested by

no test coverage detected