This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/blenloader/intern/undofile.c
Ton Roosendaal 562d6958cb Another step in the undo evolution.
- Made unified API for undo calls, to be found in space.c
  BIF_undo_push(char *str)
  BIF_undo(void)
  BIF_redo(void)
  These calls will do all undo levels, including editmode and vpaint.

  The transition is work in progress, because mesh undo needs recode.

- New global hotkey CTR+Z for undo
  Note: 'shaded draw mode' still is SHIFT+Z, the old CTRL+Z was to recalc
  the lighting in shaded mode, which already became much more interactive,
  like during/after any transform().
  Recalc hotkey now is SHIFT+ALT+Z

  CTRL+<any modifier>+Z is redo.

- For OSX users; the Apple-key ("Command") now maps to CTRL as well. This
  disables the one-mouse-button hack for rightmouse btw, will be fixed in
  next commit. At least we can use Apple-Z :)

- Old Ukey for undo is still there, as a training period... my preference is
  to restore Ukey to "reload original data" as in past, and only use new
  CTRL+Z for undo.

- Added undo_push() for all of editobject.c and editview.c. Meaning we can
  start using/testing global undo in the 3d window. Please dont comment on
  missing parts for now, first I want someone to volunteer to tackle all of
  that.

- Since the global undo has a full 'file' in memory, it can save extremely
  fast on exit to <temp dir>/quit.blend. That's default now when global undo
  is enabled. It prints "Saved session recovery to ..." in console then.

- In file menu, a new option is added "Recover Last Session". Note that this
  reads the undo-save, which is without UI.

- With such nice new features we then can also kill the disputed
  Cancel/Confirm menu on Q-KEY.

- Added fix which initializes seam/normal theme color on saved themes.
  They showed black now.... (Note: that's in usiblender.c!)
2004-09-18 12:12:45 +00:00

151 lines
3.4 KiB
C

/**
* $Id:
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2004 Blender Foundation
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
* .blend file reading entry point
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include "BLI_winstuff.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "DNA_userdef_types.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BLO_undofile.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
/* **************** support for memory-write, for undo buffers *************** */
/* not memfile itself */
void BLO_free_memfile(MemFile *memfile)
{
MemFileChunk *chunk;
while(chunk = (memfile->chunks.first) ) {
if(chunk->ident==0) MEM_freeN(chunk->buf);
BLI_remlink(&memfile->chunks, chunk);
MEM_freeN(chunk);
}
memfile->size= 0;
}
/* to keep list of memfiles consistant, 'first' is always first in list */
/* result is that 'first' is being freed */
void BLO_merge_memfile(MemFile *first, MemFile *second)
{
MemFileChunk *fc, *sc;
fc= first->chunks.first;
sc= second->chunks.first;
while (fc || sc) {
if(fc && sc) {
if(sc->ident) {
sc->ident= 0;
fc->ident= 1;
}
}
if(fc) fc= fc->next;
if(sc) sc= sc->next;
}
BLO_free_memfile(first);
}
static int my_memcmp(int *mem1, int *mem2, int len)
{
register int a= len, *mema= mem1, *memb= mem2;
while(a--) {
if( *mema != *memb) return 1;
mema++;
memb++;
}
return 0;
}
void add_memfilechunk(MemFile *compare, MemFile *current, char *buf, unsigned int size)
{
static MemFileChunk *compchunk=NULL;
MemFileChunk *curchunk;
/* this function inits when compare != NULL or when current==NULL */
if(compare) {
compchunk= compare->chunks.first;
return;
}
if(current==NULL) {
compchunk= NULL;
return;
}
curchunk= MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
curchunk->size= size;
curchunk->buf= NULL;
curchunk->ident= 0;
BLI_addtail(&current->chunks, curchunk);
/* we compare compchunk with buf */
if(compchunk) {
if(compchunk->size == curchunk->size) {
if( my_memcmp((int *)compchunk->buf, (int *)buf, size/4)==0) {
curchunk->buf= compchunk->buf;
curchunk->ident= 1;
}
}
compchunk= compchunk->next;
}
/* not equal... */
if(curchunk->buf==NULL) {
curchunk->buf= MEM_mallocN(size, "Chunk buffer");
memcpy(curchunk->buf, buf, size);
current->size += size;
}
}