//==============================================================================
SpatialComponent::SpatialComponent(SceneNode* node, const CollisionShape* shape)
	: SceneComponent(CLASS_TYPE, node)
	, m_shape(shape)
{
	ANKI_ASSERT(shape);
	markForUpdate();
}
Esempio n. 2
0
//==============================================================================
MoveComponent::MoveComponent(SceneNode* node, Flag flags)
:	SceneComponent(Type::MOVE, node),
	Bitset<Flag>(flags),
	m_node(node)
{
	markForUpdate();
}
Esempio n. 3
0
//==============================================================================
MoveComponent::MoveComponent(SceneNode* node, U32 flags)
	:	SceneComponent(MOVE_COMPONENT, node),
		Base(nullptr, node->getSceneAllocator()),
		Bitset<U8>(flags),
		m_node(node)
{
	markForUpdate();
}
Esempio n. 4
0
void deleteFilesProc(XtPointer fsel, int conf)
{
 SelFileNamesRec *fnames = (SelFileNamesRec *) fsel;
 struct stat stats;
 String name;
 int i;

 if (conf != YES)
 {
     freeSelFiles(fnames);
     return;
 }
 if (chdir(fnames->directory))
 {
     sysError(fnames->shell, "System error:");
     freeSelFiles(fnames);
     return;
 }
 if (!fnames->first)
     abort_delete = False;
 for (i = fnames->first; i < fnames->n_sel && !abort_delete; i++)
 {
     if (!(lstat(name = fnames->names[i], &stats)))
     {
	 if (!S_ISLNK(stats.st_mode) && S_ISDIR(stats.st_mode))
	 {
	     if (!(strcmp(name, ".")) || !(strcmp(name, "..")))
	     {
		 error(fnames->shell, "Cannot delete . or ..", NULL);
		 continue;
	     }
	     fnames->first = i;
	     chdir(user.home);
	     deleteDirDialog(fnames, name);
	     return;
	 }
	 else
	 {
	     if (unlink(name))
	     {
		 if (opError(fnames->shell, "Error deleting", fnames->names[i]) != YES)
		     break;
	     }
	     else fnames->update = True;
	 }
     }
     else if (opError(fnames->shell, "Error deleting", fnames->names[i]) != YES)
	 break;
 }
 chdir(user.home);
 if (fnames->update)
 {
     markForUpdate(fnames->directory, CHECK_DIR);
     intUpdate(CHECK_DIR);
 }
 freeSelFiles(fnames);
}
//==============================================================================
void cShapeTorus::scaleObject(const double& a_scaleFactor)
{
    // update dimensions
    m_outerRadius *= a_scaleFactor;
    m_innerRadius *= a_scaleFactor;

    // update bounding box
    updateBoundaryBox();

    // invalidate display list
    markForUpdate(false);
}
Esempio n. 6
0
static void renameOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
{
  XtPopdown(popups.rename);
  if (chdir(popups.fw->directory))
    sysError("Can't change directory:");
  else if (rename(popups.rename_file, popups.rename_s))
    sysError("Can't rename file:");
  else {
    clearUpdateMarks();
    markForUpdate(popups.fw->directory);
    intUpdate();
  }
}
Esempio n. 7
0
static void mkdirOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
{
  XtPopdown(popups.mkdir);
  if (chdir(popups.fw->directory))
    sysError("Can't change directory:");
  else if (mkdir(popups.mkdir_s, S_IRUSR | S_IWUSR | S_IXUSR))
    sysError("Can't make directory");
  else {
    clearUpdateMarks();
    markForUpdate(popups.fw->directory);
    intUpdate();
  }
}
//==============================================================================
void cShapeTorus::setSize(const double& a_innerRadius,
                          const double& a_outerRadius)
{
    // set new dimensions
    m_innerRadius = cAbs(a_innerRadius);
    m_outerRadius = cAbs(a_outerRadius);

    // update bounding box
    updateBoundaryBox();

    // update display list
    markForUpdate(false);
}
//==============================================================================
bool cTexture1d::setImage(cImagePtr a_image)
{
    // sanity check
    if (!a_image) return (false);

    // store new image
    m_image = a_image;

    // mark texture for update
    markForUpdate();

    // success
    return (true);
}
Esempio n. 10
0
void mkDirProc(XtPointer fnm, int conf)
{
 NewFileRec *nfr = (NewFileRec *) fnm;

 if (conf == YES)
 {
     if (chdir(nfr->directory))
	 sysError(nfr->shell, "Can't change to directory:");
     else if (mkdir(nfr->name, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH))
	 sysError(nfr->shell, "Can't make directory:");
     else
     {
	 markForUpdate(nfr->directory, CHECK_FILES);
	 intUpdate(CHECK_DIR);
     }
     XTFREE(nfr->name);
 }
 XTFREE(nfr->directory);
 XTFREE(nfr);
}
Esempio n. 11
0
static void chmodOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
{
  mode_t mode;

  XtPopdown(chmode.shell);
  mode = chmode.fw->files[chmode.file]->stats.st_mode;
  mode &= ~(S_IRUSR | S_IWUSR | S_IXUSR |
            S_IRGRP | S_IWGRP | S_IXGRP |
            S_IROTH | S_IWOTH | S_IXOTH);

  mode |= chmode.items[OWNER][READ].value     ? S_IRUSR : 0;
  mode |= chmode.items[OWNER][WRITE].value    ? S_IWUSR : 0;
  mode |= chmode.items[OWNER][EXECUTE].value  ? S_IXUSR : 0;

  mode |= chmode.items[GROUP][READ].value     ? S_IRGRP : 0;
  mode |= chmode.items[GROUP][WRITE].value    ? S_IWGRP : 0;
  mode |= chmode.items[GROUP][EXECUTE].value  ? S_IXGRP : 0;

  mode |= chmode.items[OTHERS][READ].value    ? S_IROTH : 0;
  mode |= chmode.items[OTHERS][WRITE].value   ? S_IWOTH : 0;
  mode |= chmode.items[OTHERS][EXECUTE].value ? S_IXOTH : 0;

  if (chdir(chmode.fw->directory)) {
    sysError("System error:");
    goto out;
  }

  if (chmod(chmode.fw->files[chmode.file]->name, mode)) {
    char s[0xff];
    sprintf(s, "Can't change modes for %s:", 
	    chmode.fw->files[chmode.file]->name);
    sysError(s);
  }
  else {
    markForUpdate(chmode.fw->directory);
    intUpdate();
  }

 out:
  freeze = False;
}
Esempio n. 12
0
void newFileProc(XtPointer fnm, int conf)
{
 NewFileRec *nfr = (NewFileRec *) fnm;
 int desc;

 if (conf == YES)
 {
     if (chdir(nfr->directory))
	 sysError(nfr->shell, "Can't change to directory:");
     else if ((desc = create(nfr->name, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
	 sysError(nfr->shell, "Can't create file:");
     else
     {
	 close(desc);
	 markForUpdate(nfr->directory, CHECK_FILES);
	 intUpdate(CHECK_DIR);
     }
     chdir(user.home);
     XTFREE(nfr->name);
 }
 XTFREE(nfr->directory);
 XTFREE(nfr);
}
Esempio n. 13
0
void moveFilesProc(XtPointer fsel, int conf)
{
 SelFileNamesRec *fnames = (SelFileNamesRec *) fsel;
 struct stat tostats, tolstats, frstats;
 char from[MAXPATHLEN], to[MAXPATHLEN];
 String name, cwd;
 String op_name, from_err, to_err;
 size_t toend, fromend;
 int devto, devfrom, deverr = -1, i, perm, res;
 Boolean is_dir, is_link;

 if (conf != YES || !fnames->op)
 {
     freeSelFiles(fnames);
     return;
 }
 if (chdir(fnames->directory))
 {
     sysError(fnames->shell, "System error:");
     freeSelFiles(fnames);
     return;
 }
 chdir(user.home);
 switch (fnames->op)
 {
     case COPY:
	 op_name = "Copy:";
	 from_err = "Error copying";
	 to_err = "Error copying to";
	 break;
     case MOVE:
	 op_name = "Move:";
	 from_err = "Error moving";
	 to_err = "Error moving to";
	 break;
     default:  /* i.e. LINK */
	 op_name = "Link:";
	 from_err = "Error creating symlink to";
	 to_err = "Error creating symlink in";
 }
 if (fnames->target[0] != '/' && fnames->target[0] != '~' && fnames->target != 0)
 {
     strcpy(to, fnames->directory);
     if (to[strlen(to)-1] != '/')  strcat(to, "/");
 }
 else to[0] = 0;
 strcat(to, fnames->target);
 fnexpand(to);
 if (!(cwd = absolutePath(to)))
 {
     error(fnames->shell, no_target, to);
     freeSelFiles(fnames);
     return;
 }
 strcpy(to, cwd);
 XTFREE(cwd);
 fromend = strlen(strcpy(from, fnames->directory));
 if (from[fromend-1] != '/')
 {
     from[fromend++] = '/';
     from[fromend] = 0;
 }
 devfrom = findDev(from);
 if (mountDev(devto = findDev(to), False))
     deverr = devto;
 else if (mountDev(devfrom, False))
     deverr = devfrom;
 if (deverr != -1)
 {
     error(fnames->shell, "Cannot mount device on", mntable.devices[deverr].def_mpoint);
     umountDev(devto, False);
     freeSelFiles(fnames);
     return;
 }
 if (!(stat(to, &tostats)) && S_ISDIR(tostats.st_mode))
 {
     if (chdir(to) || !(perm = permission(&tostats, P_WRITE)))
     {
	 chdir(user.home);
	 if (!perm)
	     error(fnames->shell, "You have no write permission for ", to);
	 else  sysError(fnames->shell, "System error:");
	 umountDev(devto, False);
	 umountDev(devfrom, False);
	 freeSelFiles(fnames);
	 return;
     }
     chdir(user.home);
     fnames->dirtarget = True;
     toend = strlen(to);
     if (to[toend-1] != '/')
     {
	 to[toend++] = '/';
	 to[toend] = 0;
     }
 }
 else if (fnames->n_sel == 1)  fnames->dirtarget = False;
 else
 {
     error(fnames->shell, op_name, "Target for multiple files must be a folder");
     umountDev(devto, False);
     umountDev(devfrom, False);
     freeSelFiles(fnames);
     return;
 }
 if (!fnames->first)  zzz();
 XTFREE(fnames->target);
 fnames->target = XtNewString(to);
 for (i = fnames->first; i < fnames->n_sel; i++)
 {
     name = fnames->names[i];
     if (fnames->op != LINK && (!strcmp(name, ".") || !strcmp(name, "..")))
     {
	 error(fnames->shell, "Cannot move or copy . or ..", NULL);
	 continue;
     }
     strcpy(from+fromend, name);
     if (fnames->dirtarget)
     {
	 if (fnames->op != LINK && prefix(from, to))
	 {
	     String err_str, format = "Cannot move or copy %s to";
	     err_str = (String) XtMalloc((strlen(format) + strlen(from)) * sizeof(char));
	     sprintf(err_str, format, from);
	     error(fnames->shell, err_str, to);
	     XTFREE(err_str);
	     umountDev(devto, False);
	     umountDev(devfrom, False);
	     freeSelFiles(fnames);
	     wakeUp();
	     return;
	 }
	 strcpy(to+toend, name);
     }
     if (!(lstat(to, &tolstats)))
     {
	 fnames->first = i;
	 is_dir = False;
	 if (!(stat(to, &tostats)))
	 {
	     if (S_ISDIR(tostats.st_mode))
		 is_dir = True;
	     if (!stat(from, &frstats) && tostats.st_ino == frstats.st_ino)
	     {
		 error(fnames->shell, op_name, "Source and destination are identical");
		 umountDev(devto, False);
		 umountDev(devfrom, False);
		 freeSelFiles(fnames);
		 wakeUp();
		 return;
	     }
	 }
	 if (S_ISLNK(tolstats.st_mode))
	     is_link = True;
	 else  is_link = False;

	 if (fnames->conf_ovwr || (is_dir && (!is_link || fnames->op == COPY) && resources.confirm_delete_folder))
	     overwriteDialog(fnames, to, (fnames->op == COPY && is_dir && (lstat(from, &frstats) || !S_ISDIR(frstats.st_mode)))?
			     "File copy:" : op_name,
			     is_dir && (!is_link || fnames->op == COPY));
	 else overwriteProc(fsel, YES);
	 umountDev(devto, False);
	 umountDev(devfrom, False);
	 return;
     }
     switch (fnames->op)
     {
	 case COPY:	rcopy(from, to, False); res = 0; break;
	 case MOVE:	res = movefile(from, to); break;
	 default:	res = makeLink(from, to);
     }
     if (res)
     {
	 if (opError(fnames->shell, from_err, name) != YES)
	     break;
     }
     else  fnames->update = True;
 }
 umountDev(devto, False);
 umountDev(devfrom, False);
 if (fnames->update)
 {
     if (fnames->op == COPY)
	 intUpdate(CHECK_DIR);		/* Check for new subdirectories */
     if (fnames->op == MOVE)
	 markForUpdate(fnames->directory, CHECK_FILES);
     markForUpdate(to, RESHOW);
     if (fnames->op != COPY)
	 intUpdate(CHECK_DIR);
 }
 freeSelFiles(fnames);
 wakeUp();
}