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

Function GoToObject

roomedit/source/objects.cpp:3125–3198  ·  view source on GitHub ↗

center the map around the object and zoom in if necessary */

Source from the content-addressed store, hash-verified

3123 center the map around the object and zoom in if necessary
3124*/
3125void GoToObject( int objtype, SHORT objnum)
3126{
3127 SHORT xpos, ypos;
3128 SHORT xpos2, ypos2;
3129 SHORT n;
3130 SHORT sd1, sd2;
3131 float oldscale;
3132
3133 GetObjectCoords (objtype, objnum, &xpos, &ypos);
3134
3135 // Set OrigX and OrigX to xpos and ypos
3136 OrigX = xpos;
3137 OrigY = ypos;
3138 oldscale = Scale;
3139
3140 /* zoom in until the object can be selected */
3141 // RP: Don't do it, since we dit not move mouse pointer
3142 // in window center (moving the mouse pointer is not 'politicaly'
3143 // correct in Windows)
3144 /*
3145 while (Scale < ScaleMax &&
3146 GetCurObject( objtype,
3147 MAPX( PointerX - 4), MAPY( PointerY - 4),
3148 MAPX( PointerX + 4), MAPY( PointerY + 4)) != objnum)
3149 {
3150 IncScale();
3151 }
3152 */
3153
3154 /* Special case for Sectors: if several Sectors are one inside another, then */
3155 /* zooming in on the center won't help. So I choose a LineDef that borders the */
3156 /* Sector, move a few pixels towards the inside of the Sector, then zoom in. */
3157 if ( objtype == OBJ_SECTORS &&
3158 GetCurObject (OBJ_SECTORS, OrigX, OrigY, OrigX, OrigY) != objnum )
3159 {
3160 /* restore the Scale */
3161 Scale = oldscale;
3162 for (n = 0; n < NumLineDefs; n++)
3163 {
3164 // ObjectsNeeded( OBJ_LINEDEFS, 0);
3165 sd1 = LineDefs[ n].sidedef1;
3166 sd2 = LineDefs[ n].sidedef2;
3167 // ObjectsNeeded( OBJ_SIDEDEFS, 0);
3168 if (sd1 >= 0 && SideDefs[ sd1].sector == objnum)
3169 break;
3170 if (sd2 >= 0 && SideDefs[ sd2].sector == objnum)
3171 break;
3172 }
3173 if (n < NumLineDefs)
3174 {
3175 GetObjectCoords( OBJ_LINEDEFS, n, &xpos2, &ypos2);
3176 n = ComputeDist( abs( xpos - xpos2), abs( ypos - ypos2)) / 7;
3177 if (n <= 1)
3178 n = 2;
3179 xpos = xpos2 + (xpos - xpos2) / n;
3180 ypos = ypos2 + (ypos - ypos2) / n;
3181 OrigX = xpos;
3182 OrigY = ypos;

Callers 5

CheckSectorsFunction · 0.85
CheckCrossReferencesFunction · 0.85
CheckTexturesFunction · 0.85
CheckTextureNamesFunction · 0.85
CmSearchJumpMethod · 0.85

Calls 3

GetObjectCoordsFunction · 0.85
GetCurObjectFunction · 0.85
ComputeDistFunction · 0.85

Tested by

no test coverage detected